简体   繁体   English

VS2010 DLL不更新

[英]VS2010 DLLs not updating

I have a solution (ASP.NET, .NET 4.0) that doesn't seem to be updating its dlls properly. 我有一个解决方案(ASP.NET,.NET 4.0),似乎无法正确更新其dll。 I noticed that, when I compile it after making changes, it doesn't see the additions that I've made. 我注意到,当我在进行更改后对其进行编译时,看不到我所做的添加。

I recently switched the targeted platform on the solution to x86, because we're now deploying it onto a x64 server and I am now maintaining it on a x64 Win7 machine. 我最近将解决方案上的目标平台切换到x86,因为我们现在将其部署到x64服务器上,并且现在将其维护在x64 Win7计算机上。 (I don't know if that might have something to do with it, see below.) After I isolated the problem, when I was testing, I found out that if I chose "view in browser" on one of the aspx files, it suddenly saw the changes that I had made earlier. (我不知道这是否与它有关,请参阅下文。)在隔离问题之后,在进行测试时,我发现如果我在一个aspx文件中选择了“在浏览器中查看”,突然看到了我之前所做的更改。 I combed through the directories in the main project's bin folder, and I noticed dlls were being saved to two different places: the root of the bin folder, and bin/x86/debug/. 我梳理了主项目的bin文件夹中的目录,发现dll被保存到两个不同的位置:bin文件夹的根目录和bin / x86 / debug /。 The first location was getting updated when I simply compiled the solution, and the second was getting updated when I used "view in browser" on one of the aspx files. 当我简单地编译解决方案时,第一个位置正在更新,而当我在其中一个aspx文件中使用“在浏览器中查看”时,第二个位置正在更新。

Does anyone know of an errant setting which might cause this behavior? 有谁知道可能导致此行为的错误设置?

Update: The answer provided by @Vinkal leads me to believe that Debug is looking at the bin/ folder for compiled code rather than bin/x86/debug/ , where the code is being compiled to. 更新:@Vinkal提供的答案使我相信Debug正在查看已编译代码的bin/文件夹,而不是正在将代码编译到的bin/x86/debug/ Is it possible that could be the core problem? 这可能是核心问题吗?

I combed through the directories in the main project's bin folder, and I noticed dlls were being saved to two different places: the root of the bin folder, and bin/x86/debug/. 我梳理了主项目的bin文件夹中的目录,发现dll被保存到两个不同的位置:bin文件夹的根目录和bin / x86 / debug /。 The first location was getting updated when I simply compiled the solution, and the second was getting updated when I used "view in browser" on one of the aspx files. 当我简单地编译解决方案时,第一个位置正在更新,而当我在其中一个aspx文件中使用“在浏览器中查看”时,第二个位置正在更新。

Check Configutation Manager as to what platform is selected as shown in the below screen shot#1. 检查Configutation Manager是否选择了哪个platform ,如下面的屏幕快照#1所示。

Screen shot #1: Configuration Manager 屏幕截图1:配置管理器

配置管理器

if you create the new platform (here x86 ), Output Path is automatically set to bin\\x86\\Debug\\ . 如果创建新platform (此处为x86 ),则Output Path将自动设置为bin\\x86\\Debug\\ See the screenshot below. 请参见下面的屏幕截图。

Screen shot #2: Build Settings when Project Properties is selected 屏幕截图#2: 选择“项目属性”时的“构建设置”

从项目属性生成事件选项

So when you compile the project, Binaries will be copied according to Output Path (here in my case, bin\\x86\\Debug\\ for the Platform x86 which is set in Platform Target ). 因此,当您编译项目时,将根据Output Path (在bin\\x86\\Debug\\例中为Platform Target设置的Platform x86 bin\\x86\\Debug\\复制Binaries。 Confirm as shown in the screen shot below, where all binaries are copied when you compile. 确认,如下面的屏幕快照所示,编译时将复制所有二进制文件。 As you have mentioned, when you compile the solution, Root of the bin folder is getting updated. 如前所述,编译解决方案时, bin文件夹的根目录正在更新。 So your project Output Path must be set to Root of the Bin folder for the whatever Platform (Any CPU, x86 or x64) you have set in Platform Target 因此对于您在Platform Target设置的任何Platform (Any CPU, x86 or x64)您的项目的Output Path必须设置为Bin文件夹的Root。

Note: If Post-Build event commmand is set to copy Binaries, it will also be copied to the Path specified in Post-Build event command . 注意:如果Post-Build event commmand设置为复制二进制文件,它也将被复制到Path中指定Post-Build event command

在此处输入图片说明

View in Browser: When page is opened using View in browser , page will again be compiled and Binaries are copied according to the Output Path specified in Project Properties as shown in the screen shot #2 . 在浏览器中查看:使用View in browser打开页面时,将再次编译页面,并根据Project Properties指定的Output Path复制二进制文件,如屏幕快照#2所示 As you have mentioned that bin\\x86\\Debug\\ is updated when you view the page in Browser, it indicates that Output Path is set to bin\\x86\\Debug\\ in your Project Properties , In the screen shot shown below, when page is opened using View in Browser , Binary is going to Bin folder and Platform is selected as Any CPU 正如您提到的那样,当您在浏览器中查看页面时bin\\x86\\Debug\\已更新,这表明在Project PropertiesOutput Path设置为bin\\x86\\Debug\\在下面显示的屏幕快照中,当页面为使用View in Browser打开,二进制将进入Bin文件夹,并且平台被选为Any CPU

在此处输入图片说明

Post-build event command: if you have also set the Post-build event command , as shown in the screen shot below, to copy the path in different location, in both the cases (ie when you compile and View in Browser ), it will be copied to the Path specified in Post-build event command 生成后事件命令:如果您还设置了生成Post-build event command (如下面的屏幕快照所示),则在两种情况下(即,当您View in Browser编译和View in Browser )都将路径复制到其他位置。将被复制到Post-build event command指定的Path

在此处输入图片说明

EDIT: 编辑:

As mentioned here , use the <probing> Element: 如所提到的在这里 ,可以使用<probing>元素:

You can use the element in the application configuration file to specify subdirectories the runtime should search when locating an assembly . 您可以使用应用程序配置文件中的元素来指定运行时在查找assembly时应搜索的子目录。 The following example shows how to specify directories the runtime should search. 以下示例显示了如何指定运行时应搜索的目录。

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="bin;bin2\subbin;bin3"/>
      </assemblyBinding>
   </runtime>
</configuration>

The privatePath attribute contains the directories that the runtime should search for assemblies . privatePath属性包含运行时应搜索assemblies的目录。 If the application is located at C:\\Program Files\\MyApp, the runtime will look for assemblies that do not specify a code base in C:\\Program Files\\MyApp\\Bin, C:\\Program Files\\MyApp\\Bin2\\Subbin, and C:\\Program Files\\MyApp\\Bin3. 如果应用程序位于C:\\ Program Files文件\\ MyApp的,运行时会寻找assemblies没有指定在C代码库:\\ Program Files文件\\ MyApp的\\ BIN,C:\\ Program Files文件\\ MyApp的\\斌\\ Subbin,和C:\\ Program Files \\ MyApp \\ Bin3。 The directories specified in privatePath must be subdirectories of the application base directory privatePath中指定的目录必须是应用程序基本目录的子目录

So in your case, modify the web.config as shown below 因此,根据您的情况,如下所示修改web.config

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="bin;bin\x86\debug"/>
      </assemblyBinding>
   </runtime>
</configuration>

您可以尝试通过在“工具”->“选项”->“调试”->“符号”中更改不同的配置来解决此问题。

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

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