Using the Profile Method in Silverlight

4116 단어 silverlight
Silverlight Application is a client program. It does not have and cannot access the web.config of the server. It does not allow adding .config files. How to easily change the configuration without re-publishing it? I searched many places and basically came up with a solution.
Under normal circumstances, SL App is hosted by a Web Application, and that Web Application can be easily configured, so we can consider transferring the configuration to Silverlight by the website.
The specific method, the SL object is defined by an object in the web page, such as
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"

    width="100%" height="100%">

    <param name="source" value="ClientBin/TestProject.Shell.xap" />

    <param name="onError" value="onSilverlightError" />

    <param name="background" value="white" />

    <param name="minRuntimeVersion" value="4.0.41108.0" />

    <param name="autoUpgrade" value="true" />

    <param name="InitParams" value="serviceAddress=http://localhost:8028/GeneralService.svc" />

    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0" style="text-decoration: none">

        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"

            style="border-style: none" />

    </a>

</object>
It can be seen that there is a param tag named InitParams, and its value can be obtained by using the InitParams property passed in the StartupEventArgs parameter in the Application_Startup event processing method in App.xaml.cs, and the type is IDictionary. As in the above example, I can use e.InitParams["serviceAddress"] to get the service address I set
http://localhost:8028/GeneralService.svc .

좋은 웹페이지 즐겨찾기