2014-12-08 48 views
2

我想部署我的C#ASP.Net應用程序到我的託管網站。問題是我有2個C++ DLL,應用程序使用,但與共享主機,他們不能在bin文件夾。他們在項目中引用了一個名爲'bin_native'的文件夾。該應用程序在我的機器上運行,在我的Default.aspx文件頂部的web.config和Assembly指令的運行時段中使用探測privatePath。但它不會像這樣在服務器上運行。它在加載站點時解析default.aspx時找不到dll,並在該文件頂部的2個Assembly指令中出現錯誤。Web.config system.webserver錯誤

所以我試圖在web.config的system.webserver部分添加對dll的引用。對該網站的支持表示,如果我可以這樣做,那麼應用程序可以使用位於我的網站wwwroot文件夾(其中ASP.Net bin文件夾所在的目錄)的單獨bin文件夾。這樣的應用程序可以找到DLL。

但我無法得到正確無誤的system.webserver部分。當我在我的機器上測試,我得到以下錯誤:

Server Error in '/' Application. 

Could not load file or assembly 'find_duplicates, Version=0.0.0.0, Culture=neutral, PublicKeyToken=e02ee5289fcc8248' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'find_duplicates, Version=0.0.0.0, Culture=neutral, PublicKeyToken=e02ee5289fcc8248' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

這裏是我到目前爲止所做的更改在我的項目:

的Default.aspx:

<%@ Assembly Name="find_duplicates" %> 
<%@ Assembly Name="trim_combos" %> 

網絡。配置:

<system.webServer> 

    <modules runAllManagedModulesForAllRequests="true"> 

    <add name="find_duplicates" type="find_dups.find_duplicates, find_duplicates,Version=0.0.0.0, Culture=neutral, PublicKeyToken=e02ee5289fcc8248" /> 

     <add name="trim_combos" type="trim_coms.trim_combos, trim_combos, Version=0.0.0.0, Culture=neutral, PublicKeyToken=e02ee5289fcc8248" /> 

    </modules> 

    <validation validateIntegratedModeConfiguration="false" /> 

    </system.webServer> 

<runtime> 

    <dependentAssembly> 

     <assemblyIdentity name="find_dups.find_duplicates.find_duplicates" publicKeyToken="e02ee5289fcc8248" culture="neutral" /> 

    </dependentAssembly> 

    <dependentAssembly> 

     <assemblyIdentity name="trim_coms.trim_combos.trim_combos" publicKeyToken="e02ee5289fcc8248" culture="neutral" /> 

    </dependentAssembly> 



    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 

     <probing privatePath="bin_native"/> 

    </assemblyBinding> 

</runtime> 

我的DLL是在頭文件中定義爲:

find_duplicates dll 

namespace find_dups 
class  find_duplicates 

trim_combos dll 

namespace trim_coms 
class  trim_combos 

我在集成管道模式下運行IIS的Windows 7 64位。這就是爲什麼我使用system.webserver部分而不是web.config中的system.web部分。

任何幫助,這將不勝感激。提前致謝。

+0

你能嘗試下列之一: 無論是從段或在刪除版本,區域性和公鑰部分,添加一個(對於這兩個DLL)您還可以打開程序集綁定日誌(fuslog)並查看綁定失敗的確切位置: http://stackoverflow.com/a/1527249/190476 – dotnetguy 2014-12-08 12:09:20

+0

我試圖從模塊部分刪除額外的項目,但它給了我一個運行時錯誤「無法加載類型」頁面加載時。我嘗試bindRedirect沒有運氣。如何正確找到dll版本?我嘗試了在項目中引用的dll的屬性中列出的運行時版本4.0.30319。這是正確的版本嗎?或者我需要使用Powershell來查找正確的版本?系統使用較舊的dll而不是項目中的問題是舊的dll沒有命名空間和類。但新的就是這樣。我可以參考沒有這些dll嗎? – te7 2014-12-08 18:17:42

+0

我使用Powershell來獲取DLL版本。對於我的項目DLL,當我使用[System.Reflection.AssemblyName] :: GetAssemblyName(「find_duplicates.dll」)。版本我得到0.0.0.0。但是當我使用[System.Reflection.Assembly] :: LoadFrom(「find_duplicates.dll」)。GetName()。Version我得到4.0.30319。這個東西的意思是什麼?另外它說它不在GAC中。我應該添加它嗎? – te7 2014-12-08 22:05:31

回答

1

我得到它的工作。我的dll不受管理(它們是本地模塊),因此無法爲它們加載類型,即使它們具有類和名稱空間。顯然,對於本機模塊,你只需要使用附加的名字,沒有別的,如下:

<system.webServer> 

    <globalModules> 

     <add name="find_duplicates"/> 

    </globalModules> 

    </system.webServer>