質問

I developed a Custom application that is able to consume the CRM Web services and perform Windows Live Id authentication, create, read and update operation in the CRM from the custom .NET page. It runs absolutely fine when I debug the application in Visual Studio 2010 but when I deploy the same application and try to authenticate it shows the following error:

"Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

I just wanted to know how to install the Microsoft.IdentityModel assembly using a startup task.I followed some of the steps in the following link:

http://blogs.msdn.com/b/sriharsha/archive/2012/04/07/windows-azure-unable-to-find-assembly-microsoft-identitymodel.aspx

But was unable to add RegisterDLL.cmd to my project solution.

役に立ちましたか?

解決

Well,

You can use what Sandrino suggests, but you can also use this powershell script. I use it in couple of project and it works fine. It also auto-recognizes Windows Version (because for Azure Guest OS Family 1.xx you have to use the Windows6.0-xxxxx, and for Guest OS Family 2.xx you have to use Windows6.1-xxx version of the KB update).

You can execute that powershell script in a very simple startup task. Create one setup.cmd file, that you have the following content:

@echo off
powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out
powershell .\Install-WIF-OnAzure.ps1 2>> err.out

And run it as simple startup task:

 <WebRole name="AzureAndWif" vmsize="Small">
    <Startup>
      <Task commandLine="setup.cmd" executionContext="elevated" />
    </Startup>
   ...
 </WebRole>

Hope this also helps ;)

他のヒント

What do you mean by "was unable to add RegisterDLL.cmd to my project solution"? In Visual Studio, just follow these steps:

  1. Right click on your project
  2. Choose Add > New Item > Text File
  3. Enter the following code (from the blog post):

    @echo off
    sc config wuauserv start= demand
    wusa.exe "Windows6.1-KB974405-x64.msu" /quiet /norestart
    sc config wuauserv start= disabled
    exit /b 0
    
  4. Rename the file to RegisterDLL.cmd

  5. In the properties, set Copy to Output Directory to Copy always
  6. Go to File > Save as. On the Save button, click the small arrow and choose Save with Encoding
  7. Choose Unicode (UTF-8 without signature) - Codepage 65001

This should be enough to have a working file. Now follow the rest of the guide and redeploy your application.

If you are deploying this to Windows Azure then make sure "copy local" is set to true on the Microsoft.IdentityModel when you deploy to Azure.

-----------**Update**----------------------------

Cloud Tip #9-Add Microsoft.IdentityModel to the GAC with a Startup Task

http://blogs.msdn.com/b/benko/archive/2012/04/07/cloud-tip-9-add-microsoft-identitymodel-to-the-gac-with-a-startup-task.aspx

This should help...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top