简体   繁体   English

在Visual Studio 2010中使用64位程序集的ASP.net页面

[英]ASP.net Pages With 64 Bit Assembly in Visual Studio 2010

Short Version : 简短版本

I'm using a 64bit dll (system.data.sqlite) in an Asp.net MVC app in VS 2010. The application runs and debugs fine, but all the aspx and ascx pages show errors when editing in Visual Studio 2010 and intellisense doesn't work. 我在VS 2010中的Asp.net MVC应用程序中使用了64位dll(system.data.sqlite)。应用程序运行和调试很好,但是在Visual Studio 2010中进行编辑时所有aspx和ascx页面都显示错误并且intellisense没有不行。

This is a VS2010 regression bug . 这是一个VS2010回归错误 Does anyone have a work around? 有没有人有工作?

(OR) (要么)

Does anyone know of a free, reliable, production ready embeddable database that doesn't cause a 32/64 bit problem? 有谁知道一个免费,可靠,生产就绪的可嵌入数据库,不会导致32/64位问题?

More Details 更多细节

Apparently this worked in Visual Studio 2008 and this has been is a known regression bug in Visual Studio 2010 for several months . 显然这在Visual Studio 2008中有效, 这已经是Visual Studio 2010中已知的几个月的回归错误 I don't want to revert to VS 2008 and I don't want to debug in 32 bit mode. 我不想恢复到VS 2008,我不想在32位模式下调试。

I have web application that needs to debug and deploy as a 64 bit mode because it uses uses some unmanaged 64 bit dll's like system.data.sqlite. 我有一个Web应用程序需要调试和部署为64位模式,因为它使用一些非托管的64位DLL像system.data.sqlite。 Also, I prefer debugging in 64 bit mode because it allows us to test some high memory use cases. 此外,我更喜欢在64位模式下进行调试,因为它允许我们测试一些高内存使用情况。

After a lot of fiddling, Asp.net will deploy and run just fine. 经过大量的摆弄,Asp.net将部署并运行得很好。 However all the aspx and ascx pages show errors and intellisense doesn't work when editing them in Visual Studio 2010. Apparently this worked in Visual Studio 2008 and this has been is a known problem in Visual Studio 2010 for months . 但是,在Visual Studio 2010中编辑它们时,所有aspx和ascx页面都显示错误并且intellisense不起作用。显然这在Visual Studio 2008中有效,并且这已经是Visual Studio 2010中已知的问题已有数月 I don't want to revert to VS 2008. 我不想回归VS 2008。

There was a work around posted on SO here but it didn't work in my tests, limits debugging to 32bit mode, and also feels a bit hacky (I think it only works for VS Express style websites). 有一个工作在这里张贴在SO,但它在我的测试中没有用,限制调试到32位模式,也觉得有点hacky(我认为它只适用于VS Express风格的网站)。 Has anyone made this work in a web application or have a better work around? 有没有人在网络应用程序中完成这项工作或有更好的解决方法?

For those who are interested Visual Studio 2010 has two other problems with 64bit dlls that I have managed to work around. 对于那些感兴趣的人,Visual Studio 2010还有另外两个64位dll的问题,我已经设法解决这些问题。

Problem 1 - Cassini: Cassini can only debug in 32 bit mode 问题1 - Cassini: Cassini只能在32位模式下调试

Solution 1 - CassiniDev or Localhost: Debug using localhost or compile CassiniDev (an opensoure variant of cassini) in 64bit mode. 解决方案1 ​​ - CassiniDev或Localhost:使用localhost调试或在64位模式下编译CassiniDev(cassini的opensoure变体) I like the zero config simplicity of debugging a new web app with cassini so I used CassiniDev. 我喜欢使用cassini调试新的Web应用程序的零配置简单性,所以我使用了CassiniDev。 You just stick the dlls in C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer\\10.0 and it works (I recommended making a backup of the Cassini version you will be over writing). 你只需将dll粘贴在C:\\ Program Files(x86)\\ Common Files \\ microsoft shared \\ DevServer \\ 10.0中它就可以了(我建议备份你将要编写的Cassini版本)。

Problem 2 - MSTest: By default unit tests run with MSTest fail to load 64bit dlls . 问题2 - MSTest:默认情况下,使用MSTest运行的单元测试无法加载64位dll

Solution 2 - AnyCPU & 64bit host process Instructions here , set local.testsettings to AnyCPU & 64bit host process 解决方案2 - AnyCPU和64位主机进程 这里的说明 ,将local.testsettings设置为AnyCPU和64位主机进程

I'm starting to think the whole setup is too little hacky and I'm on the verge of giving up and restructuring my application to not use a 64bit dll. 我开始认为整个设置太少hacky,我即将放弃并重组我的应用程序,不使用64位dll。 I'm also really disappointed that Visual Studio 2010 caused all these problems. 我对Visual Studio 2010引发所有这些问题感到非常失望。 Can somebody make MS fix the regression bug they created? 有人能让MS修复他们创建的回归错误吗?

Or, 要么,

We want to use an embeddable database. 我们想使用嵌入式数据库。 Does anyone know of a free, reliable, production ready embeddable database that doesn't cause the 32/64 bit problem? 有没有人知道一个免费,可靠,生产就绪的可嵌入数据库,不会导致32/64位问题?

I had an x64 dll in the bin directory of a web site project. 我在网站项目的bin目录中有一个x64 dll。 The web site would run in an IIS 64 bit application pool, but it failed to run in Cassini. 该网站将在IIS 64位应用程序池中运行,但无法在Cassini中运行。 Visual Studio also threw errors (incorrect format) every time I opened a page which made the IDE painfully slow. 每次打开一个让IDE痛苦地慢的页面时,Visual Studio也会抛出错误(格式不正确)。

Web site projects (unlike web application projects) are dynamically compiled. 网站项目(与Web应用程序项目不同)是动态编译的。 However Visual Studio will only use the 32 bit aspnet_compiler. 但是,Visual Studio将仅使用32位aspnet_compiler。 This is true when using the page inspector or when using the Compile Web Site menu item. 使用页面检查器或使用“编译网站”菜单项时,会出现这种情况。 I can find no way to change this behavior. 我找不到改变这种行为的方法。 IIS on a x64 bit will uses the x64 version of aspnet_compiler for dynamic compilation and everything works great. x64位上的IIS将使用x64版本的aspnet_compiler进行动态编译,一切都很好。

The only workable solution to get Visual Studio to stop throwing errors was to remove the x64 dll from the bin directory and load it dynamically at run time as stated here . 唯一可行的解决方案,使Visual Studio中停止引发错误是删除从bin目录中的64 DLL和规定在运行时动态加载它在这里

This can be accomplished by using assemblyBinding and probing in your web.config file. 这可以通过在web.config文件中使用assemblyBindingprobing来完成。 The privatePath must be a sub directory of your application directory and not outside the application directory. privatePath必须是应用程序目录的子目录,而不是应用程序目录之外的目录。

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="dlllocation" />
    </assemblyBinding>
  </runtime>
<configuration>

You also need to add code to any aspx file BEFORE the @Page directive 您还需要在@Page指令之前将代码添加到任何aspx文件

<%@ Assembly Name="fileNameWithoutExtension" %>
<%@ Import Namespace="NameSpace" %>

I'm afraid there may not be a work around that enables 64bit debugging Asp.net with a 64bit unmanaged dll dependency that won't break the web forms editor. 我担心可能没有一个解决方案可以使64位调试Asp.net具有64位非托管DLL依赖关系,它不会破坏Web窗体编辑器。 I'm thinking the VS Asp.net team considers 64bit dependencies an edge case and will fix the webforms editor when they have time... be warned. 我认为VS Asp.net团队认为64位依赖项是一个边缘案例,并且会在有时间时修复webforms编辑器......请注意。

You can always debug in 32bit mode and then deploy 64bit without proper testing. 您始终可以在32位模式下进行调试,然后在未经适当测试的情况下部署64位。

I'm planning to avoid the issue by replacing sqlite with a persistent key/value solution based on managed esent. 我打算通过用基于托管的esent的持久性密钥/值解决方案替换sqlite来避免这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM