.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘Runtime’

BUG: AppDomainUnloaded exception when you use managed extensions for Visual C++ components

Symptoms
This problem occurs when a call is made from unmanaged code to managed code, including direct unmanaged-to-managed calls within a single DLL. For example, the problem may occur when MEC++/IJW is used in ASP.NET applications. In ASP.NET, various events can cause applications to be reloaded into a new AppDomain. If you are using MEC++ components and IJW in this application, you may receive an AppDomainUnloadException error message.
Resolution
As part of the implementation of IJW, when a managed DLL that you created by using the C++ compiler loads, the runtime creates thunks for transitions from unmanaged code to managed code. These thunks contain a reference to the AppDomain in which the DLL loads. The runtime does not re-create these thunks if the DLL loads again; also, the runtime does not update the reference when the original AppDomain unloads and the DLL loads in another AppDomain.
When the program performs a transition from unmanaged code to managed code, the program uses the outdated AppDomain reference to run the managed code. Even if the original AppDomain is still loaded, the code cannot access static fields because the fields are specific to the AppDomain.

BUG: A Client That Is Linked with the Soapsuds Proxy DLL Throws a Remoting Exception at Run Time

Symptoms
When a client is linked with the proxy DLL that the Soapsuds tool (Soapsuds.exe) generates, the client throws a remoting exception atrun time. You may receive an error message that is similar to thefollowing error message:

Unhandled Exception: System.Runtime.Remoting.RemotingException:Permission denied for activating type soap:TestClass,http://schemas.microsoft.com/clr/nsassem/EchoExeTest/ServerExe%2C%20Version%3D0.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull.Server stack trace: atSystem.Runtime.Remoting.Activation.ActivationListener.Activate(IConstructionCallMessagectorMsg) atSystem.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBasemb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext,Object[]& outArgs) atSystem.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessagemsg, Int32 methodPtr, Boolean fExecuteInContext)
Resolution
To work around this problem by linking the client, followthese steps:Run the Remoting Server application, and then generate theproxy by using the following command:

soapsuds -url:<ServerUrl?wsdl> -oa:serverexe.dllRun the remoting server.Generate the proxy code by using the following command:

soapsuds -url:<ServerUrl?wsdl> -gcOpen the .cs file that Soapsuds.exe generates,remove the SoapType attribute from the class, and then build the proxy.Link the proxy to the client, and then runSoapsuds.exe.
Note If the remoting server is not running, Soapsuds.exe generates anerror and does not generate the proxy code.