Solved

c# vs2013 corrupt .dll

Posted on 2016-09-04
4
40 Views
Last Modified: 2016-09-06
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
Comment
Question by:jetbet
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Stefan Hoffmann
ID: 41785065
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
 

Author Comment

by:jetbet
ID: 41785363
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
 
LVL 1

Accepted Solution

by:
Stefan Hoffmann earned 500 total points
ID: 41785565
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
 

Author Closing Comment

by:jetbet
ID: 41787153
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now