在 Windows Azure 上配置会话

发布于 2024-10-15 01:50:34 字数 2030 浏览 5 评论 0原文

我正在使用本地系统在 Windows Azure 上测试会话。我已经在 web.config 中完成了以下配置,

<appSettings>
    <!-- account configuration -->
    <add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1/" />
    <add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1/" />
    <add key="AccountName" value="devstoreaccount1" />
    <add key="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
    <add key="DefaultMembershipTableName" value="Membership" />
    <add key="DefaultRoleTableName" value="Roles" />
    <add key="DefaultSessionTableName" value="Sessions" />
    <add key="DefaultProviderApplicationName" value="ProviderTest" />
    <add key="DefaultProfileContainerName" />
    <add key="DefaultSessionContainerName" />
  </appSettings>
  <system.web>

    <sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
      <providers>
        <clear />
        <add name="TableStorageSessionStateProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" />
      </providers>
    </sessionState>
</system.web>

但现在出现以下错误

配置错误描述:An 处理过程中发生错误 所需的配置文件 服务此请求。请查看 下面的具体错误详细信息和 修改你的配置文件 适当地。

解析器错误消息:异常 被目标投掷 调用。

来源错误:

第 39 行:第 40 行:
第41行:第42行:第42行 43:

源文件: C:\Users\GizaKarthik\Desktop\SessionDemo\SessionDemo\SessionDemo_WebRole\web.config 线路:41

程序集加载跟踪:以下内容 信息可以帮助 确定装配原因 'Microsoft.WindowsAzure.StorageClient, 版本=1.0.0.0,文化=中立, PublicKeyToken=31bf3856ad364e35' 可以 未加载。

警告:程序集绑定日志记录是 关闭。启用程序集绑定 失败记录,设置注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 到 1。 注意:有一些 与相关的性能损失 程序集绑定失败日志记录。转动 关闭此功能,删除注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

I m using the local system to test session on windows azure. I have done the following config in web.config

<appSettings>
    <!-- account configuration -->
    <add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1/" />
    <add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1/" />
    <add key="AccountName" value="devstoreaccount1" />
    <add key="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
    <add key="DefaultMembershipTableName" value="Membership" />
    <add key="DefaultRoleTableName" value="Roles" />
    <add key="DefaultSessionTableName" value="Sessions" />
    <add key="DefaultProviderApplicationName" value="ProviderTest" />
    <add key="DefaultProfileContainerName" />
    <add key="DefaultSessionContainerName" />
  </appSettings>
  <system.web>

    <sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
      <providers>
        <clear />
        <add name="TableStorageSessionStateProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" />
      </providers>
    </sessionState>
</system.web>

but now i an getting the following error

Configuration Error Description: An
error occurred during the processing
of a configuration file required to
service this request. Please review
the specific error details below and
modify your configuration file
appropriately.

Parser Error Message: Exception has
been thrown by the target of an
invocation.

Source Error:

Line 39: Line 40:
Line 41: Line 42: Line
43:

Source File:
C:\Users\GizaKarthik\Desktop\SessionDemo\SessionDemo\SessionDemo_WebRole\web.config
Line: 41

Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'Microsoft.WindowsAzure.StorageClient,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' could
not be loaded.

WRN: Assembly binding logging is
turned OFF. To enable assembly bind
failure logging, set the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog]
(DWORD) to 1. Note: There is some
performance penalty associated with
assembly bind failure logging. To turn
this feature off, remove the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog].

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

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

发布评论

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

评论(1

玩物 2024-10-22 01:50:34

异常的原因是我使用了损坏的 dll。从此处下载其他 C# 示例。找到asp提供的项目编辑TableStorageSessionstateProvider中的代码

找到这段代码

            else            
            {     
                    byte[] items = Convert.FromBase64String(reader.ReadLine());
                    byte[] statics = Convert.FromBase64String(reader.ReadLine());
                    int timeout = session.Timeout;
                    // Deserialize the session
                    result = DeserializeSession(items, statics, timeout);

            }

用这个替换上面的代码

            else
            {
                try // Added try statement   
                {
                    // Read Items, StaticObjects, and Timeout from the file
                    byte[] items = Convert.FromBase64String(reader.ReadLine());
                    byte[] statics = Convert.FromBase64String(reader.ReadLine());
                    int timeout = session.Timeout;
                    // Deserialize the session
                    result = DeserializeSession(items, statics, timeout);
                }
                catch (Exception e) // Added catch statement
                {
                    // Return an empty SessionStateStoreData   
                    result = new SessionStateStoreData(new SessionStateItemCollection(),
                                                       SessionStateUtility.GetSessionStaticObjects(context),
                                                       session.Timeout);
                }

            }

然后编译并使用dll。它应该像冠军一样工作。快乐编码!!

The reason for the exeption is that i used a corrupted dll. Download the additional c# examples from here . Find asp provides project edit the code in TableStorageSessionstateProvider

find this code

            else            
            {     
                    byte[] items = Convert.FromBase64String(reader.ReadLine());
                    byte[] statics = Convert.FromBase64String(reader.ReadLine());
                    int timeout = session.Timeout;
                    // Deserialize the session
                    result = DeserializeSession(items, statics, timeout);

            }

replace the above code with this

            else
            {
                try // Added try statement   
                {
                    // Read Items, StaticObjects, and Timeout from the file
                    byte[] items = Convert.FromBase64String(reader.ReadLine());
                    byte[] statics = Convert.FromBase64String(reader.ReadLine());
                    int timeout = session.Timeout;
                    // Deserialize the session
                    result = DeserializeSession(items, statics, timeout);
                }
                catch (Exception e) // Added catch statement
                {
                    // Return an empty SessionStateStoreData   
                    result = new SessionStateStoreData(new SessionStateItemCollection(),
                                                       SessionStateUtility.GetSessionStaticObjects(context),
                                                       session.Timeout);
                }

            }

Then compile and use the dll. It should work like a champ. happy coding!!

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