-1
FileVersionInfo.GetVersionInfo("~/bin/MyFile.dll").FileVersion

When I make this call, I get the following error:

"Cannot evaluate expression because the code of the current method is optimized"

Is there any way to get the version of a DLL in an ASP web app? Code behind is VB... but I'm guessing it doesn't matter if it's VB or C#.

It must work in RELEASE, and when the app is deployed to a production environment. I've searched the interwebs but only found a lot of DEBUG vs. RELEASE config.

I've also tried this with no help:

http://torulflundgren.blogspot.com.au/2010/03/cannot-obtain-value-of-local-or.html

Thanks in advance!

PaulyWally
  • 11
  • 5
  • What does the title of your question have to do with the question itself? – Scott Chamberlain Sep 15 '17 at 21:06
  • what is fqFileName ? – Hüseyin Burak Karadag Sep 15 '17 at 21:07
  • Fixed. Sorry about that. – PaulyWally Sep 15 '17 at 21:08
  • Possible duplicate of [Programmatically get the version number of a DLL](https://stackoverflow.com/questions/1755504/programmatically-get-the-version-number-of-a-dll) – tonythewest Sep 15 '17 at 21:09
  • This is NOT a duplicate. The link posted by tonythewest mentions nothing about the error I am receiving. I also tried using AssemblyName.GetAssemblyName(@"c:\path\to\file.dll").Version and I receive the exact same exception: "Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away." – PaulyWally Sep 18 '17 at 12:50

1 Answers1

0

FileVersionInfo representing the version information associated with the specified file.

I try this on my custom dll, this work correctly

    FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(@"C:\HBK.SystemCore.dll"); 

    string version = fvi.FileVersion;