错误 1 Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. D:\3layerhotel\WebSite_hotel\UserRegist.aspx 5
下面是解决过程:
先查找GAC的定义
GAC
GAC中的所有的Assembly都会存放在系统目录"%winroot%\assembly下面。放在系统目录下的好处之一是可以让系统管理员通过用户权限来控制Assembly的访问。
除了系统默认放置在GAC中的Assembly如System.Windows.Forms以外,我们也可以添加自己的Assembly:
1)创建一个strong-name的Assembly,例如ToolbarComponent.dll
2)运行gacutil -i ToolbarComponent.dll,把这个Assembly添加到GAC
3)在程序中动态装载:
System.Reflection.Assembly ass=Assembly.Load("ToolbarComponent, Version=1.0.934.20434, Culture=neutral, PublicKeyToken=65f45658c8d4927f");
MessageBox.Show("Is the assembly loaded from GAC? "+ass.GlobalAssemblyCache);
在上面的程序中,ToolbarComponent就是从GAC装载而不是从程序的运行目录下的dll文件中装载,程序目录下不需要放置ToolbarComponent.dll程序也能正常运行。另外,Assembly.Load()中的参数可以通过"gacutil -l"查到。
另外,上面提到了GAC中的Assembly必须是strong-name的。创建strong-name的Assembly的步骤大致如下:
a) 在命令行运行“sn -k keyPair.snk”创建一个密钥文件。这里的sn.exe也是.NET附带的一个工具。
b) 在VS.NET里面修改“AssemblyInfo.cs”文件:
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("..\\..\\keyPair.snk")]
c) 编译项目,就能得到一个strong-name的Assembly。
asp.net 2.0的水晶报表,在迁移机器的时候,如果目标机器没有相应的程序集,在IIS中会报错。
错误描述:Parser Error
Description: An error occurred during the parsing of a resource required to service this
request. Please review the following specific parse error details and modify your source file
appropriately.
Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.WebForms,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.