views:

82

answers:

1

I'm sorry if this is a dumb question, but I've been trying for hours with no luck , and maybe one of you can help.

I have a class/library project I made in Visual Studio, a Spreadsheet in the SS namespace. Next, I created a windows form application, I then added the DLL, and put it in my resources menu, and it builds just fine, however, at runtime, I get a TryLoadException, which the documentation seems to say it's not in the assembly, but then why does it compile just fine? Also, I doubt it is a problem with my DLL, as my friend made a similar DLL (matching the same APIs, but build differently, and it works for his windows form application), and I still get the TryLoadException. Any feedback would be greatly appreciated.

Here is the procedure I made.

  1. Create (and implement) the spreadsheet class.
  2. Create a new solution and project for the spreadsheet gui.
  3. In the project, right click and add an existing item, the dll found in the first solutions bin/debug (or bin/release, I tried both) folder. Also added the dll to the references.
  4. Somewhere in the code that get's executed, add the line:

    Spreadsheet ss = new Spreadsheet(); // There both in the same namespace already

  5. Build, note that there are no errors.

  6. Run, execution stops right there with the TryLoadException.

Thank you for your help.

A: 

You put the DLL in your resources menu? That seems really strange.

Some things to try. First, after the build, go and look in the Windows Forms project's Debug (or Release, whichever you are about to run) folder. You should see your exe there and also this DLL you need. If not, there is a problem with the way you set the reference, such as not having CopyLocal or something else.

Second, if your DLL and your Windows Forms app are projects in the same solution, use a Project Reference instead of browsing to the DLL. This will make life a little simpler.

Third, try double-clicking the exe instead of pressing F5 and see if that affects anything. (The current directory is different in these two cases which is often relevant when trying to find DLLs.)

Fourth, try removing the reference, taking the DLL away from Resources or whatever strange place it is now, and adding the reference again. See if things behave better then.

Kate Gregory
No, that's not what I meant. I added the dll itself to the root directory of the project, but I put it in my reference list so I could link to it. Anyway, thank you. For some magical reason it started working today. I'm still not entirely certain what happened, but it works now, thank you.
Leif Andersen