I wrote a managed wrapper in C++/CLI and compiled it under AMD64.
Now I wrote a client in C++/CLI too and this works well.
Trying to do the same in C# I got everything to compile but when I run it it says:
Unhandled Exception: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E) at MyClass.Main()
This is weird though. I compiled the C# file for 'anycpu' but trying to set the platform to x64 did not do any difference.
The class library is even located in the same directory.
It was compiled using the RC:
csc /out:test_cs.exe test.cs /reference:net64.dll
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.26
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
The same thing happens in both C# and VB whereas the C++/CLI client works just fine.
What am I missing here Actually I am not even sure what file is missing since it does not say in the error message. I just assumed it's my class library.
Thanks in advance.
-- Henrik

Unable to load class library
Rati
I Can see that is a problem of the 64 bit compiler, see this post for more help:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=94312&SiteID=1
I was runing my code in a 32 bit OS.
AbhijitB
Maybe, I'm using the Final Version of VS2005.
JMDavis
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=06e0a0c8-30a4-498f-999e-ce06daa355ed
-- Henrik
Simone Romano
I tried what you said with the example above but once I got it to compile it runs but at the same time gives a runtime error.
I get a messagebox saying theres a runtime error R6034.
Did you also get that
/clr:pure is not an option for me though. I am creating a mixed mode library which contains unmanaged code also.
Should I assume that this is a really critical bug
-- Henrik
Paul L
I found out the R6034 runtime error problem is related to the redist files. The seem to cause _LOTS_ of problems on my x64 machine when I put them into \windows\system32. I'm running Windows XP pro x64 on that machine.
I got them from \c\Program Files (x86)\Microsoft Visual Studio 8\VC\redist\amd64\Microsoft.VC80.CRT
but it seems it was a big mistake since it got my machine to act very weird and I got lots of R6034's in other programs too e.g. when deleting a file in explorer.
amonteiro
It's good to see this
Greg WCAS
There are a few things I can think of:
Note: RPC calls are allowed between a 64-bit and 32-bit process.
bsteve
cl /clr /O2 /MD /c a.cpp
link /dll /out:a.dll a.obj
csc /out:test.exe b.cs /reference:a.dll
test.exe runs without any problem. It just won't run for any other name
Ruben Sainiuc
>The C# compiler is different than the C++ compiler in the sense that the output >files are created directly and do not not require a linker, therefore there is no >object output (.obj).
No this is not the case. Why do you mention obj files This should be unnessecary. Only the resulting class library matters which is a dll.
Your other points are not valid for my case either. All is compiled and run on AMD64 so no Cross-OS stuff is going on.
>If possible, debug the process and generate debug information by using >the /debug switch on the compiler. Run the process using a CLR debugger (Free >with the 2.0 SDK) and use the Modules window to view what modules are being >loaded, and attempted to be loaded.
I tried doing that but without luck. No matter what it shows this error and the CLR debugger does not post any information at all.
Since I still cannot get it working I did a small repro. Could someone be kind to compile this code and tell me if it works on your platform or not. I am interested to see if it works on Win32.
File a.cpp:
#using <mscorlib.dll>
using namespace System;
public
ref class A{
public:
void CallMe()
{
Console::WriteLine("Yeay --- I was called");
}
};
File b.cs:
using
System;public
class B{
static void Main()
{
A a = new A();
a.CallMe();
}
}
Then compile them as:
cl /clr /O2 /MD /c a.cpp
link /dll /out:a.dll a.obj
csc /out:b.exe b.cs /reference:a.dll
Now run b.exe
All I get is a file not found by the VM loader.
Thanks in advance.
-- Henrik
ahewgill
As for the runtime error I guess it's something that is fixed in the final compiler
almaz
cmcauliffe
Lots of good reasons for using C++/CLI goes away if you cannot assume working code.
So the next obvious quesion should be if C# and C++/CLI does not work together, will VB and C# I already tested that VB and C++/CLI does not work either. So how about J# and the other languages
I surely hope for a resolusion fast.
-- Henrik
jhusain
Joseph Karpinski
cl /clr:pure /O2 /MD /c a.cpp