为什么我的 MVC 应用程序将 GetExecutingAssembly 名称报告为 App_web_xxxxx.dll?
我正在将 CruiseControl.NET 持续集成环境从使用旧的 Visual Studio 2008 Web 部署项目更新为 Visual Studio 2010。
我不想使用 Beta 2010 Web 部署项目,因为我认为我可以利用更新的发布/打包2010 年。
目前我已成功配置 CruiseControl 脚本来调用 MSBuild 两次。首先在发布配置中构建解决方案,然后打包 MVC 项目。
然后,我从可怕的文件路径中的包中复制出正确的文件(这让我怀疑我做得不对,但是嘿)并将转换后的 web.configs 复制到测试服务器。
这终于可以工作了,但与我使用 2008 部署项目时不同,此代码将 ExecutingAssembly 返回为 App_web_xxxxx.dll,而不是我所追求的 Company.Product.Web.dll。
Dim CurrentAssembly As Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim version As String = CurrentAssembly.GetName.Version.ToString
我知道 GetName 返回的字符串比名称更长,但我正在调试它以查看它包含的内容。我知道这是编译/缓存的 dll,但为什么它不是 MVC bin 中的那个。
干杯
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.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了这一点 - 基本上是当我在 footer.ascx 中调用 Assembly.GetExecutingAssembly 时。这意味着代码位于页脚动态编译的 dll 中。
我想要的是 MVC 网站的 DLL。因此,我在控制器上使用了一个扩展属性,该属性使用程序集信息设置 ViewStates。
就我而言,我想再次使用此代码,因此扩展属性位于不同的 Assemmly 中,我可以将其包含在各种 MVC 项目中。这意味着我必须更改代码才能使用 Assembly.GetCallingAssembly,但它现在完全按照我想要的方式工作。
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.