Why does my MVC application report the GetExecutingAssembly Name as App_web_xxxxx.dll?
I am updating our CruiseControl.NET continuous integration environment from using the old Visual Studio 2008 Web Deployment projects to Visual Studio 2010.
I do not want to use the Beta 2010 Web Deployment projects as I think I can make use of the updated Publishing/Packaging in 2010.
Currently I have managed to configure the CruiseControl script to call MSBuild twice. First to Build the solution in the Release configuration and then to Package the MVC project.
I then copy out the correct files from the Package from a hideous file path (which makes me suspect I am not doing this right but heh) and the Transformed web.configs to the Test server.
开发者_Python百科This is finally working but unlike when I used the 2008 Deployment Projects this code returns the ExecutingAssembly as App_web_xxxxx.dll and not Company.Product.Web.dll which is what I'm after.
Dim CurrentAssembly As Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim version As String = CurrentAssembly.GetName.Version.ToString
I know GetName returns the a longer string than just the name but I'm debugging it to see what it contains. I understand that is is the compiled/cached dll but why isn't it the one in the MVC bin.
Cheers
I figured this out - basically when I was calling Assembly.GetExecutingAssembly inside the footer.ascx. This meant that the code was in a dynamically compiled dll for the footer.
What I wanted was the DLL for the MVC website. So I used an extension property on the controller that set ViewStates with the Assembly information.
In my case I will want to use this code again so the extension property is in a different Assemmly that I can include in various MVC projects. This meant I had to change the code to use Assembly.GetCallingAssembly but it now works exactly how I wanted.
精彩评论