SL+WCF+LINQ 問題階段性小結

1)      In WCF Hosted Project or Web Solution , Make DataContext  (DMBL) Seriable:

Set SerializationMode=Unidirectional

If not , when client application try to generate the WCF services WSDL will error occurred , Because some object can’t be serialized .

This problem may be not occurred in local machine even the version if RELEASE .

But   it will occurred in remote server .

 

2)Make WCF use basicHttpBinding

(If your wcf is in your web application then modify it in WebApplication web.config file

else if your wcf is a standalone application then modify it in its' web.config)

 

      3)Make the sl use the wsdl directly copied from the Serivice.svc Start Page

(this will make sure the sl and the wcf used the same port, and this will affect

the services.config in sl project will different)

 

4) 以下三個步驟,在傳輸大數據時WCF出錯,顯示404 錯誤時,檢查一下幾個配置是否正確。

# Bind your Web.config inside webservice with bindingConfiguration="LargeBuffer" where LargeBuffer is declared like this

   <bindings>

      <basicHttpBinding>

        <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"

           maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

        </binding>

      </basicHttpBinding>

    </bindings>

 

# Then, inside ServiceReferences.ClientConfig, you should have this

<system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="BasicHttpBinding_Buffer" maxBufferSize="2147483647"

                    maxReceivedMessageSize="2147483647">

                    <security mode="None" />

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

            <endpoint address="http://3water/SteveWeb/SteveService/Service.svc"

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Buffer"

                contract="SteveSLWeb.SteveWebService.IService" name="BasicHttpBinding_Buffer" />

        </client>

    </system.serviceModel>

 

# The most important thing here is to make sure your webservice and your web is in the same port [yourweb]:#port if they are in the different ones, errors should occur. By the way, you can use IIS to host your Web, and the trick can be easily done. Moreover, if you use IIS, make sure you have put the clientaccesspolicy.xml onto the wwwroot with this format

<?xml version="1.0" encoding="utf-8"?>

<access-policy>

  <cross-domain-access>

    <policy>

      <allow-from http-request-headers="*">

        <domain uri="*"/>

      </allow-from>

      <grant-to>

        <resource path="/" include-subpaths="true"/>

      </grant-to>

    </policy>

  </cross-domain-access>

</access-policy>

 

5) 需要調試時,將下列CODE寫入HOST WCFWEB.CONFIG(直接在根節點下面)。如果是APP,則寫入APP.EXECONFIG. 生成的SVCLOG文件,可以用WINDOWS SDK中的Trace Log File Viewer 看。否則很難分析。

 <system.diagnostics>

    <sources>

      <source name="System.ServiceModel"

              switchValue="Information, ActivityTracing"

              propagateActivity="true">

        <listeners>

          <add name="traceListener"

              type="System.Diagnostics.XmlWriterTraceListener"

              initializeData= "c:/log/Traces.svclog" />

        </listeners>

      </source>

    </sources>

  </system.diagnostics>

 

6) 如果碰到404的錯誤,說某個System.Web.dll找不到。然後先前又改過Asp.net的頁面或者項目,

原因未明。但是可以關閉重新開啓項目後成功運行 . 如果不行,還可以另外刪除Bin Obj目錄。

 

7)如果IIS中不能解析Xap的包,那麼說明還沒有註冊MIME類型。

Extension : .xap

MIME Type : application/x-silverlight-app

 

Just open the properties dialog of virtual path , and add a MIME type

 

8)使用IsolatedStorage的時候保存自定義類型對象可以使用類似如下代碼: 讀取時類似

 

                IsolatedStorageSettings.ApplicationSettings[ISO_BIGP_CACHE] = GlobalInfo.CurBigPhotoDict;

                IsolatedStorageSettings.ApplicationSettings.Save();

 

 

 

Summary :

 

 1)SL不支持Style,templateTriggler

 

2)Sl不支持Pack:url....的資源定位,可以直接用相對目錄定位

 

3)SL不支持WCF處傳出的FAULTException,無論什麼EXCEPTION,它最終都會定位到一個最簡單的EXCEPTION

所以得不到WCF出來的詳細錯誤信息。這個問題MS那邊要有段時間才能解決。

暫時可以用OUT的參數給WCF,然後在MethodName_Completed的方法調用結束方法中使用鋼材的OUT參數。

 

4)SL的庫必須是SL創建出來,不能和。NET庫通用。

 

5)SL BETA2 也有很多小版本,需要注意。

裝了2008SP1後,需要重新安裝新版本的SL2BETEA2

 

6) The web application embedded the sl control, and sl call the wcf method to retrive the data

and the wcf use Linq to Sql to get data from sql server

7)All Method in SL are Async

8)If the wcf project is standalone(not hosted in the asp.net web application ) .It is Cross-Domain .

When Cross-Domain ,it need two Policy Configuration file ,It will be more complex .)

9)If pop silverligth need exclued in the web application warning , just set the web application as startup project.

10) the WPF and Silverlight runtime are completely different. WPF uses Windows Image Component (WIC) to handle bitmap images, while Silverlight has a home grown bitmap image component. There may be some problems in WIC that some specific images can't be decoded. If you encounter any of them, try to use a tool such as Windows Paint and Expression Design to recreate the image

 

11) MIME Type issue .

If the server which host IIS , is not configured MIME Type of Silverlight, when the pc which not installed the silverlight before will download a wrong version of silverlight.

Check and change the MIME type when such problem occurred.

12)關於IsolatedStoragedFile

在使用ISO的時候,有一點要注意,如果數據爲Dictionary<string,List<CustomDataObject>>

則需要確定CustomDataObject以及他的LIST 沒有被CLEAR或者DISPOSE過。否則由於是引用對象的問題,將導致ISO中沒有此數據.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章