0

I have a normal winforms app. I run it and it calls some logic in another .dll (another project part of the solution). I get an error (my own exception) saying could not load assembly etc etc.

I've used the assembly log viewer but could not find an issue - all I found was that the windows service the program uses was installed/deployed on another account. My winforms app calls this service, which in turn calls logic in its own and different .dlls.

Could this be an issue? Thanks

0

4 Answers 4

1

If you use a FileDialog and open/save/write a file to another directory other than the one that contains your exe/dlls, it will change the programs working directory if you do not set the FileDialog.RestoreDirectory = true. This one caused me fits for a while, and would explain why it appears intermittent.

Sign up to request clarification or add additional context in comments.

4 Comments

This is the most likely cause of an "intermittent" failure. Of course, looking for DLLs in the working directory is a bad idea to begin with.
How/where do I set that value?
RestoreDirectory is a property of FileDialogs. For example, if you are using an OpenFileDialog called ofd, just set ofd.RestoreDirectory = true. The would apply for a SaveFileDialog as well.
I don't use that. Just call various classes etc.
0

Check your project .NET Framework version, and your assembly .NET Framework version, problem could be there.

Regards.

Comments

0

Make sure the assembly it's looking for is in the same directory that you're running the application from, or that it's registered in the GAC (Global Assembly Cache) - and that it's the correct version.

Comments

0

Make sure your application and all its dependencies are either all 32 bit or all 64 bit assemblies.

4 Comments

How do I do that? This problem is intermittent btw.
@blade33: Bitness isn't intermittent, so this is probably not the problem in your case. Run dumpbin /headers and dumpbin /clrheader on a .DLL or .EXE to find out the platform.
You can also check the configuration manager in Visual Studios, which is where you would fix it if it is wrong (and then recompile).
By intermittent, do you mean that it sometimes successfully loads the problem assembly (if so I agree with Ben, bitness is not the problem), or is it possible you your application only sometimes tries to load the promblem assembly?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.