.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 ‘dll’

BUG: Various errors may occur when you try to call managed code from unmanaged code in Visual C++ .NET 2003

Symptoms
You have a Microsoft Visual C++ .NET 2003 application that uses multiple application domains. When you try to call managed code from unmanaged code in a DLL that has already been loaded in another application domain, you may receive the following error message:

An unhandled exception of type ‘System.NullReferenceException’ occurred in mscorlib.dll
Additional information: Object reference not set to an instance of an object.Note In some scenarios, you may receive one of the following error messages:

DllNotFoundException

Illegal Instruction
Resolution
You may notice this problem if your application contains unmanaged code and uses multiple application domains.
For example, if you have an application that uses multiple application domains that use a set of DLLs, you can successfully load and use these DLLs in the first application domain. However, when you try to call the managed code in one of these DLLs from unmanaged code in a different (second) application domain, the behavior that is mentioned in the “Symptoms” section of this article occurs. The application does not load the managed code in the second application domain because the code has already been loaded in another application domain that is in the same process.

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 reference to ‘<typeLibrary>’ could not be added” error message when you try to add a project reference to a COM DLL

Symptoms
When you try to add a project reference to a Component Object Model (COM) DLL in Microsoft Visual Studio .NET, you may receive an error message that is similar to the following:

A reference to ‘C:\MyCOMDLL\Debug\MyCOMDLL.dll’ could not be added. Converting the type library to a .NET assembly failed. Could not load type MyCOMDLLLib.MyClassClass from assembly Interop.MyCOMDLLLib, Version=1.0.0.0.
Additionally, when you try to convert the type definitions that are found in a COM DLL by using Microsoft Type Library Importer (Tlbimp.exe) from a command prompt, you may receive an error message that is similar to the following:

TlbImp error: System.TypeLoadException – Could not load type MyCOMDLLLib.MyClassClass from assembly MyCOMDLLLib, Version=1.0.0.0.
Resolution
You may notice the behavior that is mentioned in the “Symptoms” section when the following conditions are true: Your DLL contains a class (such as MyClass) that implements an interface (such as IMyClass) that in turn derives from a base interface (such asIBaseClass).The IMyClass interface contains a method (such as Test) that has the same name as a property that the IBaseClass interface has.You notice this behavior because of the mechanism that Tlbimp.exe uses to disambiguate member names. Under the previous conditions, when the Microsoft .NET Framework tries to create a method implementation to associate the Test method of the MyClass class with the corresponding interface method, the .NET Framework does not know the name of the corresponding interface method. Therefore, Tlbimp.exe generates a System.TypeLoadException error, and then you receive the error message that is mentioned in the “Symptoms” section.
When you try to add a project reference to a COM DLL, Visual Studio .NET internally runs Tlbimp.exe and then handles any generated exceptions. Therefore, under the previous conditions, Visual Studio .NET handles the generated System.TypeLoadException, and then you receive the error message that is mentioned in the “Symptoms” section.

Application Exception in Spoolss When Printing

Symptoms
When you use the Citrix ICA client and are connected to a server configuredusing the Metaframe add-on to Microsoft Terminal Server, you may receive aDr. Watson error in Spoolss if using the HP LaserJet 4000 printer.

Application exception occurred:App: exe\spoolss.dbg (pid=74)When: 9/14/1998 @ 14:28:14.841Exception number: c0000005 (access violation)
Resolution
This issue may be caused because you may have a mismatched version of theHpdcmon.dll file, or the Hpdcmon.dll file may be corrupted, or it may beunnecessary for proper operation.

“Ie5wzd caused an exception in module Msjava.dll or Kernel32.dll” error message when you run Office 2000 Setup

Symptoms
When you run Office Setup, you may receive an error message similar to one of the following:

Ie5wzd caused an exception in module Msjava.dll
-or-

Ie5wzd caused an exception in module Kernel32.dll
Resolution
This behavior may occur for either of the following reasons: The Microsoft Java Virtual Machine (VM) is damaged.
-or-NetZip is installed on your computer.