Activator.CreateInstance fails : "Value does not fall within the expected range"

Feb 13, 2012 at 11:05 AM
Edited Feb 13, 2012 at 3:29 PM

Hi we get an error when dynamically loading an assembly with that has the Cudafy.dll and our cuday code in : 

                   IMyGpuLib result = Activator.CreateInstance(type) as IMyGpuLib;

This fails when it gets to the

km = CudafyTranslator.Cudafy();

 error :

"Value does not fall within the expected range"

 

 Any ideas on what else we need to reference or do ?

 

 

Coordinator
Feb 14, 2012 at 6:13 PM

Difficult to really help when you don't say what 'type' is.

Are you using the individual DLLs rather than the single release DLL?  Can you step through your code and find the source of the exception?  Cudafy.dll depends on CUDA.NET.dll.  CudafyTranslator is also in its own DLL.

Feb 15, 2012 at 8:20 AM

I am using the single dll Cuday.Net 1.7.4364.27657, in an assembly, which all works fine.  Now I loaded the dll dynamically then created an instance of it, which worked fine, where I can create a class in the dll however the code runs up to the point of the translator when I get that error.

 

I can send source if you wish?

 

thanks

Wayne

Coordinator
Feb 15, 2012 at 8:55 AM

I think the dynamic loading may not go down well with the translation process.  The translator makes use of reflection which may lead to general bad news when used in this way.  If you need to go down this road you could try to use the Cudafy command line tool.  This is documented in the V1.8 release which came out yesterday.  Failing that you could build the separate dlls yourself from the sources.

Feb 15, 2012 at 11:15 AM

ok thanks, will try another way with v1.8.