为什么我会收到“无法加载类型”消息我的自定义 SessionStateProvider 出错?

发布于 2024-08-27 04:21:03 字数 440 浏览 6 评论 0原文

我的同事为我创建了一个自定义 SessionStateProvider 以便与我的 ASP.net 应用程序一起使用。我将文件 CustomSessionStateProvider 添加到我的 VS2008 Web 应用程序项目中,并将适当的引用放入 web.config 中,它工作正常。

但是,我的主管希望我将其设置为 GAC 参考。在我的办公室,我们创建了许多 DLL,将其用作不同项目的 GAC 引用。

如果我将 CustomSessionStateProvider 添加到全局程序集缓存,我的页面会抛出 无法加载类型 CustomASP.CustomSessionStateProvider 错误。只需从 GAC 中删除 DLL 即可使其再次工作,但我想将其设置为 GAC 参考。

什么可能导致这个问题?

My associate has created a custom SessionStateProvider for me to use with my ASP.net application. I add the file CustomSessionStateProvider to my VS2008 Web Application Project and put the appropriate reference in the web.config and it works fine.

However, my supervisor wants me to set this up as a GAC reference. At my office, we have many DLLs we've created that we use as GAC references across different projects.

If I add my CustomSessionStateProvider to the Global Assembly Cache, my pages throw a could not load type CustomASP.CustomSessionStateProvider error. Simple removing the DLL from the GAC makes it work again, but I want to set this up as a GAC reference.

What could be causing this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

金兰素衣 2024-09-03 04:21:03

您需要更改 web.config 以完全包含 您班级的限定名称。它看起来像这样:

CustomASP.CustomSessionStateProvider, CustomASP, Culture=neutral, PublicKeyToken=XXXXX 

假设程序集名为“CustomASP”,并且该类位于也称为“CustomASP”的命名空间中,并且类名称为“CustomSessionStateProvider”。此外,您可能已经知道,您的程序集需要经过签名才能进入 GAC。因此,您应该将 XXXX 更改为用于签名的密钥的公钥令牌。

希望有帮助。

You need to change your web.config to include the fully qualified name of your class. It would look something like this:

CustomASP.CustomSessionStateProvider, CustomASP, Culture=neutral, PublicKeyToken=XXXXX 

This assumes that the assembly is called "CustomASP" and that the class is in a namespace also called "CustomASP" and that the class name is "CustomSessionStateProvider". Furthermore, as you probably already know, your assembly needs to be signed to be in the GAC. Therefore you should change XXXX to the public key token of the key you use for signing.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文