Cudafy Failed to resolve assembly error when starting from another process

Sep 24, 2013 at 3:53 PM
I have a working 64bit application using cudafy. When I run the app in debug from VS2010 (Win 7 64bit), the app runs correctly without problems. When I run the app directly from the windows folder as a standalone app I also have no problems.

I am now trying to run the app from another process. Basically the new process checks that the cudafy app is running, if not then it starts the app using Process.Start(). When trying to start the cudafy app in this manner, the cudafy app throws the following exception :

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void GPUBaskets.Program::GPU_CalcFitness(Cudafy.GThread,System.Single[0...,0...],System.Int32[0...,0...],System.Int32[0...,0...],System.Int32,System.Int32,System.Int32[],System.Single[0...,0...],System.Single[],System.Single[],System.Single[],System.Single[],System.Single[])
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Cudafy.NET, Version=1.26.5007.36008, Culture=neutral, PublicKeyToken=63a4c9931616906b'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver, TypeReference type)
at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver, MethodReference method)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.IntroducePropertyAccessInstructions(ILExpression expr, ILExpression parentExpr, Int32 posInParent)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, ILAstOptimizationStep abortBeforeStep)
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable1 parameters, ConcurrentDictionary2 localVariables)
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDefinition methodDef, DecompilerContext context, IEnumerable1 parameters, ConcurrentDictionary2 localVariables)
--- End of inner exception stack trace ---
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDefinition methodDef, DecompilerContext context, IEnumerable1 parameters, ConcurrentDictionary2 localVariables)
at Cudafy.Translator.CUDAAstBuilder.CreateMethod(MethodDefinition methodDef)
at Cudafy.Translator.CUDALanguage.DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
at Cudafy.Translator.CudafyTranslator.DoCudafy(CudafyModule cm, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(IEnumerable`1 props, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(eArchitecture arch)
at GPUBaskets.Program.SetupGPU()

The app that calls the cudayfy app uses calling code that looks like this:
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.WindowStyle = ProcessWindowStyle.Normal;
                    psi.FileName = processGPUBasketsPath;
                    processGPUBaskets = Process.Start(psi);
The cudafy app throws the error when setting up the cudafy process

CudafyModule km = CudafyTranslator.Cudafy(eArchitecture.sm_30);

I have tested the latest v1.26 build and see the same problems as with 1.25. Please let me know if I can provide any more details to help resolve this.

As always any ideas would be appreciated. Thanks
Coordinator
Sep 25, 2013 at 6:53 AM
You may need to put the CUDAfy dll in the GAC.
Sep 25, 2013 at 9:33 AM
NickKopp wrote:
You may need to put the CUDAfy dll in the GAC.
Thanks, worked perfectly. To others who need to do this, I followed the instructions at : http://msdn.microsoft.com/en-us/library/ex0ss12c.aspx

Basically you open the VS2010 Command Prompt (run as Administrator), change to the directory that the Cudafy.NET.dll is in, then run "gacutil -i Cudafy.NET.dll"

I'm not sure what happens when the next release comes out if I can simply do the same with the new version or if there will be some overwritting issue but for the moment this solved my problem.
Sep 25, 2013 at 7:14 PM
Have you considered setting the process working directory pointing to the dll's location?
process.StartInfo.WorkingDirectory = ...;
Sep 26, 2013 at 9:47 AM
WorkingDirectory solved a similar problem for me