473,421 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

CLR Runtime not finding an assembly even though it is loaded and running

1
OS: Windows XP (32 bit)
NET: .Net 2.0 runtime
DevEnv: VS 2008 C++ and C#

I am attempting to use an unmanaged C++ library to load a managed C# assembly and hand off control. I have the following in my C++ routine:

Expand|Select|Wrap|Line Numbers
  1. ICLRRuntimeHost*        Clr = NULL;
  2. HMODULE                 hMsCorEE = LoadLibraryA("mscoree.dll");
  3. PROC_CorBindToRuntime*  CorBindToRuntime = (PROC_CorBindToRuntime*)GetProcAddress(hMsCorEE, "CorBindToRuntime");
  4.  
  5. CorBindToRuntime(NULL, NULL, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (void**)&Clr));
  6.  
  7. ClrHost->Start();
  8.  
  9. Clr->ExecuteInDefaultAppDomain("MyLib", L"MyNamespace.MyClass", L"MyMethod", MyParams, &RetVal);
  10.  
This code is actually working in that the library is being loaded and my class.method is executed. However in my method there is code that is attempting to de-serialize some of the data being passed in as the parameter string which is throwing an exception as follows:

System.Runtime.Serialization.SerializationExceptio n: Unable to find assembly 'MyLib, Version=2.5.0.5, Culture=neutral, PublicKeyToken=4b580fca19d0b0c5'.

Even though the code that was executing at the time of the exception was the very library that is not being found.

I did some testing to determine what the runtime believes the full name of the currently executing assembly to be and I got the following depending on the method I used to retrieve it:

CODE:
Expand|Select|Wrap|Line Numbers
  1.             Assembly SampleAssembly;
  2.             Int32 Integer1 = new Int32();
  3.             Type Type1;
  4.            SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
  5.             file.WriteLine("FullName=" + SampleAssembly.FullName);
  6.  
Output:

FullName=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

CODE:
Expand|Select|Wrap|Line Numbers
  1.             Type t = typeof(System.Data.DataSet);
  2.             file.WriteLine("FullNameAgain=" + t.Assembly.FullName.ToString());
  3.  
Output:

FullName=System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I have seen sparse reference to potential complications resulting from the method CLR uses to locate assemblies, but nothing is clear as to how I can overcome this, other then having MyLib registered in the GAC which does bypass the problem. However, I am trying to eliminate the need to manage the code in the GAC. It would seem that I am missing something since I am able to load and run the managed code, but the library name is not being loaded with the assembly (or at least not correctly)...

Any ideas would be appreciated.

Thanks.

creo
Nov 17 '08 #1
0 1688

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Outshined | last post by:
I have a class library where just about every class uses its static initializer to register with a central registry object in the same assembly. I am hoping for some sort of Assembly.Load event...
2
by: Mike Talbot | last post by:
Hello I've got a windows service checking every x minutes (Timer) on a job. The job execution takes place in a separate assembly that is called in the timer_elapsed event. After the job...
1
by: Kent Rollins | last post by:
I am writing a server and an MMC console app that use remoting to talk to each other. The MMC client and the server share a couple of assemblies: one has the interface that is remoted from the...
5
by: jon morgan | last post by:
Hi, I am trying to clean out all the VB specific code in a project before porting to C#. Having removed all the import references I still see the VB runtime is loaded at startup. How can I pin...
2
by: Robb Sadler | last post by:
I am trying to write several hardware interfaces that would use the same base class and functions and be implemented differently. I don't want to ship all of the interfaces, but want to access...
8
by: Rick Strahl [MVP] | last post by:
Hi all, I'm building an app that uses the ASP.Net runtime... One problem I've run into is that pages running inside of the runtime are not finding DLLs in the GAC. In fact, if I look at the...
7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
5
by: Luis Arvayo | last post by:
When I load an assembly at runtime, that is to say, a plugin DLL through Assembly.Load, an old version of the assembly is loaded. If I recompile the DLL and then copy the result to where the...
4
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.