assembly does not allow partially trusted callers - asp.net

I am building a site using fluent NHibernate, which works just fine on the dev box.
However, after I uploaded it to my host I get the following when trying to run it.
"System.TypeInitializationException: The type initializer for 'NHibernate.ByteCode.Castle.ProxyFactory' threw an exception. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
Is this something I will need to resolve with the hosting company (CrystalTech)?
Any help much appreciated.
The rest of the inner exception:
at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly, String strongAssemblyName, String strongModulePath, String weakAssemblyName, String weakModulePath) at Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly) at Castle.DynamicProxy.ProxyGenerator..ctor() at NHibernate.ByteCode.Castle.ProxyFactory..cctor() The action that failed was: LinkDemand The Zone of the assembly that failed was: MyComputer
--- End of inner exception stack trace ---

nHibernate does not work out of the box on a medium-trust environment (which most shared hosts run your application under). Lazy Loading with nHibernate Under Medium Trust describes some of the steps taken to try to get it working.

Related

Can post to server DB from localhost, but when published to server I get "error: 52 - Unable to locate a Local Database Runtime installation."

I have a simple web app that interacts with a Microsoft SQL Server 2016 Standard Edition that is hosted on it's own server, in the same environment. When I run the app locally, it connects just fine and posts to the DB with no problem. After I published the app to our app hosting server I get the following error:
error: 52 - Unable to locate a Local Database Runtime installation.
I'm wondering why it is even talking about a local database when I am connected to a DB on a server, which was initially working. I know the connectionString works because it connects to the DB and posts just fine from localhost.
<connectionStrings>
<add name="PickemContext" connectionString="Data Source=ISSQLTEST01; user id=pickem; Password=pickem"
providerName="System.Data.SqlClient" />
</connectionStrings>
Here is the error.
The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
And it keeps going with more stuff in the stack trace.
How can I go about troubleshooting this? Its confusing to me that it works and posts to the DB just fine from localhost but throws an error talking about localDBs when trying to post from the hosted app. When looking at the table data displayed on the hosted app, it loads everything in fine, all the data that's in this table. The problem just seems to be with posting.
Ok I fixed the issue. The issue was not my connection string in Web.config. When I was making the app, I had to add some functionality to the Create method in the controller, and I had set a "conString" String variable because parts of this method needed the connectionString. This variable was still holding the original connectionString which points to a localDB. I just replaced that with the proper connectionString and now it is all good.

Why does connection string has to be in the client side project and not DAL?

Well, I have two projects:
Blog.Core (a class library project for my entites as well as data access code)
Blog (ASP.NET MVC Project)
I installed EF in Blog.Core. Then added reference to Blog.Core in Blog. I have specified my connection string in Blog.Core since this is my DAL. Now when I run the project I get the following error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I deleted the connection string form Blog.Core and placed it in Blog project, and it works. Why is that? Doesn't this break the architecture because client-side has the database connection string? I mean isn't that correct that only DAL should be responsible for connection strings and database operations. Why was my first (and, according to me, more logical) solution not working?
There has been lots of argument about this one and you can refer to this thread C# DLL config file

how would I resolve this error: Unable to contact the RDS server "data services on Tomcat (localhost) connection refused: connect

I'm making a program in flash builder 4.5 using WebOrb 4 (which is fantastic, I might add). When I go to deploy, however, it gives me this error:
>There was an error during model deployment for xxxxProgram.
>
>The server returned the following message:
>
>Unable to contact the RDS Server "Data Services on Tomcat (localhost)."
>
>Connection refused: connect
>
>Do you want to continue launching your Flex application?
I've poked around online for a solution, but for the most part I either don't understand them (forum grammar can be somewhat obtuse) or the answer in the post doesn't apply.
Any ideas?
the message that you received was thrown by the flash builder and the following part is quite confused:
"Unable to contact the RDS Server "Data Services on Tomcat
(localhost).""
Most likely, the root of the problem is the incorrect server address in your configuration. The WebORB RDS servlet (you are using WebORB for Java, aren't you?) is mapped to the /rds.wo url, so first of all I would recommend to check if the RDS servlet is up. If so, you should verify is your URL from project settings matched to you actual url where WebORB is running .
Additionally, please have a look on the WebORB plugin documentation step by step just to verify if everything is OK. The documentation is available here
Finally, if you will find nothing, please let me know the version of WebORB that you are using.

Word Component in C#

I am using component of Microsoft.Office.Interop.Word.dll on C#.But when i run it on IIS,I am receiving the following error.
Retrieving the COM class factory for component with
CLSID {000209FF-0000-0000-C000-000000000046} failed
due to the following error: 80070005.
if I allow 32-bit applications on IIS,I am receiving the following error.
”Validation of viewstate MAC failed. If this application is
hosted by a Web Farm or cluster,
ensure that <machineKey> configuration specifies the
same validationKey and validation algorithm.
AutoGenerate cannot be used in a cluster”
I am entering the following line into web.config file.
<system.windows.forms jitDebugging="true"/>
if I run again , that's gives me error.
Microsoft Word encountered a problem.
Description: An unhandled exception occurred during the execution
of the current web request. Please review the
stack trace for more information about the error and
where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException:
Word encountered a problem.
Source Error:
Line 711:
Line 712: //ADDING A NEW DOCUMENT TO THE APPLICATION
Line 713: oWordDoc = oWord.Documents.Add(ref yol, ref oMissing,
ref oFalse, ref oTrue);
Line 714:
Line 715: // SELECT END
By the way, I am using IIS 7 64-bit on Windows Server 2008.
How can i solve this problem?
Thanks in advance.
Error (or HRESULT) 0x80070005 translates to E_ACCESSDENIED which means you've got a permissions problem somewhere.
Make sure your web site's identity has permissions to access Word.
Also make sure your application pool's enable32BitOppOnWin64 setting is configured to match whatever processor architecture your Word app is targeted at.

What does error ORA-12571 (TNS:packet writer failure) mean in a Web Service?

Background: I'm calling a Web Service written in ASP.NET that queries an Oracle database. I know the Web Service itself works, because I've used it before other applications. So I have a web application in Visual Studio that I've been switching back and forth to point from a 'DEV' web service to a production configured version of the same web service for testing. Pointing to the 'DEV' configured web service is no problem, but calling the production version I always get an exception calling the service:
SoapException was unhandled by user code
Server was unable to process request. ---> could not execute query
[ SELECT this_.FIELD1 as FIELD1_18_0_, this_.FIELD2 as FIELD12_18_0_ FROM ABC.TABLE_A this_ WHERE this_.FIELD1 like :p0 ORDER BY this_.FIELD1 asc ]
Positional parameters: #0>00073%
[SQL: SELECT this_.FIELD1 as FIELD1_18_0_, this_.FIELD2 as FIELD12_18_0_ FROM ABC.TABLE_A this_ WHERE this_.FIELD1 like :p0 ORDER BY this_.FIELD1] ---> ORA-12571: TNS:packet writer failure
I ran the SQL queries against the appropriate database (cut and pasted straight out of the exception message) and the query came back with the expected data. I've tried updating and re-adding the Web Service reference both as a "Service Reference" (.NET 3.0+ way) and as a "Web Reference" (Older .NET way), and both give the same error.
Question: So, what does a "ORA-12571: TNS:packet writer failure" error mean in the context of a Web Service? Looking up the Oracle Error number gives some very vague possible causes such as "loose cable connection" or "IP address conflict". I'm fairly certain it's neither of these, since a different application is currently successfully using that Web Service. Possibly some kind of configuration error, or maybe something more subtle? Anyone else seen this vexing Oracle error number being attributed to something web-service related?
Your call is going from the ws client to the ws server to the oracle database.
Your error is an ORA error, which is generated by the database. So your problem is probably between the ws server and the database.
When you ran "the SQL queries against the appropriate database", did you do it from the web server? If not could you try that. Make sure that you are using the same connection configuration.
EDIT
As per the comment below, the real problem was a driver mismatch.
I would suggest re-examining your assumptions more carefully, as this is clearly an error in the web-service dialogue with the db and should be completely independent of the w/s caller.
If the w/s call is generating this specific exception, it should be doing so for all other invocations, so your 'other application' that's using the web service successfully is simply not executing the same code or there are outside factors at play.
Either way, it's unrelated to how the service is registered or invoked.

Resources