Windows Live Messenger Addinでセキュリティの制限をなくす

Windows Live Messenger AddinでAddinを作る際に、ネットワークに
アクセスしたり、ファイルアクセスしたりすると.NET Frameworkのコードアクセス
セキュリティによって、例外が発せられ、次のようなエラーが出てしまう。

「型 System.Net.NetworkInformation.NetworkInformationPermission,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 の
アクセス許可の要求に失敗しました。」

これを防ぐためには、Global Assembly Cache(GAC)にプログラムを
登録する必要がある。

方法としては、アセンブリの署名を作って、GACに登録をする。
具体的な手順としては、以下のサイトに次のように書いてある。

Coding4Fun : Building your own Windows Live Messenger Events Agent
http://blogs.msdn.com/coding4fun/archive/2007/03/08/1837770.aspx

----- 引用開始 -----
Add-ins run under Code Access Security (CAS) and are not allowed to call any web service.
Since our primary purpose is to work with Windows SharePoint Services web services,
we need to override this behavior. We can achieve that by installingthe assembly in the
Global Assembly Cache (GAC); assemblies deployed in GAC must be Strong-Named Assemblies.

To digitally sign the assembly, go to Project Properties > Signing > Sign the assembly
and check the box; choose or create a new strong name key file.

To install the assembly in the GAC you should use the developer tool named gacutil which is
easily available in the Visual Studio 2005 Command Prompt. I used the build events to automatically
install my assembly: go to Project Properties
(in C#) or Project Properties > Compile (in VB) > Build Events > Post-build event
command line and enter "$(DevEnvDir)....SDKv2.0Bingacutil.exe" /i "$(TargetPath)".
From now on, every time there is a successful build, the output assembly is automatically
installed in the GAC for you; be sure to compile the project at least once before
using the add-in with the messenger.
----- 引用終了 -----

登録したファイルは、自分の環境ではローカルでの移動は問題なかった。
おそらく、証明書の内容を確認しているためだと思う。

WORDの記事を書いている最中に、そういえばと思って調べてみたら、見つけることができた。
今までは、Officeアイコンが表示されて、しかも文字が青色で何となく嫌だったけど、
これで、通常のPersonal Messageとして表示することができる。
一応、Windows Live MessengerのAddin形式で動作するようになっているので、
あとは、設定ダイアログとかをつけたらよくなると思う。
動作サンプルとしては、今のこちらのメッセンジャーの状況を見てみてください。
公開などについては、できればしたいですが、時間があまりないので当分は公開できなさそうです。
もし、ソースコードが欲しいなど要望があれば、コメントしてもらえれば渡します。

とりあえず、WORDの記事とドイツ語のテスト勉強・・・。
ぁー、あと、先生にメールを送らないといけないのか。。。

Posted at : 2007-10-17 18:33:30 / Category : none

Comments

まだコメントはありません / No comment.

Send comment


Name


Mail-address (empty is OK. If you want to notify update, please fill mail-address.)


Bot check code (240426 と入力してください / Please input 240426.)