Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 86
  • Last Modified:

c# vs2013 corrupt .dll

I have created a library for use in some of my applications. It loads information into various classes in memory and keeps itself updated.

Recently I updated it due to a small issue. This went through developer and UAT testing without an issue.

There is an issue where it goes from working correctly to throwing an error that one of the fields on one of the classes does not exist. Needless to say this does exist and is initialized correctly.

Part of the investigation was to start an application that uses the .dll into Visual studio. I put a breakpoint at a point where a function is called that uses the field that I have the problems with but when the problem exists I cannot step into the function for some reason. If I check the object before the function is called I can also see the field that is supposedly missing.

This function is called often without an issue until this particular issue decides to show itself.

How could a compiled .dll seemingly change behaviour after it has been working correctly for hours and what would stop me stepping into the code that uses it (a few lines into the function)?
0
jetbet
Asked:
jetbet
  • 2
  • 2
1 Solution
 
Stefan HoffmannCommented:
I remember I had funny errors with libraries before, but that was a GAC issue. I had the same library (something.dll) in the same version (1.0.0.0) registered in the GAC and in the softwares directory. The version in the GAC is preferred, so when I changed the library and deployed the software I ran into problems because my changes did not apply. It took quite some time to find it.

Maybe it is something like that? Did you maybe register your library to the GAC?
0
 
jetbetAuthor Commented:
What would be the best way to release a new version of my .dll to my target machines? In this instance I copied the existing folder, renamed it, and dropped the new .dll into it.

So do I also need to rebuild the Application that uses it (it resides in the same directory as the executable) and how can I look on the target machine to see what version (or path to it) that it is using?
0
 
Stefan HoffmannCommented:
Since I do not know about how you changed the code, I do not know if your application is compatible with your new dll or not. If the dll and the application depend on each other (share an interface) I'd include them into one solution in Visual Studio. Thus I never deploy a version of a dll without having built it with the application. I did not try this out yet. It should work if you do not change any parameters.

I have the following ideas that may help you:

How To find the version number:
You find the information about the version number in the file version information using explorer. Just go to the file, right click it, go to properties->details and take a look at the version number. Since you have the source of the dll file, you could change the version number there slightly so you can see the difference.

ildasm:
Another approach would be using ildasm to verify the contents of the dll and your application.
https://msdn.microsoft.com/de-de/library/f7dy01k1(v=vs.110).aspx
Here you can have a look at the compiled code directly, so you can see if the changes are in fact part of the content or if you have been tricked by some deployment issue.
There are .Net decompilers available that may be of even more help, since they can show you a c# source code derived from the compiled stuff.

Delete-It-Test:
To be certain that you do not by accident load a different version of the dll you could delete the dll from the directory and start the application. If it starts you know this may be not the version that is loaded after all. Then checking the GAC is highly recommended. Because it probably contains the version that is loaded then.

Different .Net Framework Versions of the library and the application?
You may run into weird issues if the library and the application are compiled for different .net versions.

Copy distribution works mostly fine with .Net Applications. I only once ran into a problem where the .Net Frameworks differed between development and production machine because one of the machines had all windows updates installed and the other one nearly none and somehow some method had been changed in the .Net Framework.

Let me know what you find.
0
 
jetbetAuthor Commented:
Thanks for your help.

It looks as though I need to recompile the application if I want to change the .dll version
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now