2013-10-09 42 views
3

我們在我們的AX環境中添加了一個C#項目。我們最近對app.config文件進行了修改,清理並重建了項目,並將其部署到了AOT。如果我進入SqlServer Management Studio並查詢VSASSEMBLIES表,我可以看到相應的.dll和.dll.config文件。我爲.dll.config轉儲內容並將其轉換回文本以確保表中的版本是最新版本,並且是。Dynamics AX 2012 DLL配置文件沒有更新

問題是,當AOS重新啓動時,.dll.config文件永遠不會寫入磁盤(C:\ Program Files \ Microsoft Dynamics AX \ 60 \ Server [Instance] \ bin \ VSAssemblies)。 .dll會被寫出來,但不會被配置。如果我擦除整個目錄並重新啓動AOS,則除了我們的配置文件外,所有內容都會被寫回。

EInvoiceCFDI_MX.dll的配置文件被寫出來,所以我已經搜尋他們的項目文件和配置,並且不能提出他們已經設置的任何我們沒有的東西。

我看到的唯一的事情是在AOT中,EInvoiceCFDI_MX項目顯示項目輸出下的.dll.config文件,我們沒有。我檢查了默認構建腳本引用的中間目標,它清楚地顯示app.config應該被複制到項目輸出中,但由於某些原因,它不是。

我錯過了什麼?


一月,感謝您的帖子。

我們正在構建/的方式配置服務您參考:

CLRObject clientType = CLRInterop::getType("OurService"); 
OurService client = AifUtil::createServiceClient(clientType); 

的createServiceClient()拋出一個異常:

System.Reflection.TargetInvocationException: Exception has been thrown by the 
target of an invocation. ---> System.InvalidOperationException: Unable to find 
the application configuaration file C:\Users\<user>\AppData\Local\Microsoft\ 
Dynamics Ax\VSAssemblies\OurService.dll.config. 

的OurService.dll.config文件是在AOT,但當服務器或客戶端啓動時,它不會寫入磁盤。

回答

1

您是否更改了全局app.config?別!

取而代之的是使用AifUtil::CreateServiceClientas explained here使項目配置文件可用。

更改配置文件?這是可行的,但類庫的 配置文件存儲在模型存儲區中,並由 客戶端/服務器下載。除非在AOT中更改它,否則無法更改, 將重建Visual Studio項目,此時客戶端/服務器 將從模型存儲庫下載新版本。因此,您可以將所有的app.config設置複製/粘貼到AX32(serv).exe.config 文件中並在此處進行更改。那麼你將不需要使用aifUtil :: createserviceclient的 。無論如何,這是非常不切實際的, 尤其適用於在客戶端運行的服務!

Technet article: 以下示例代碼顯示如何構造和配置服務客戶端對象爲兵服務。要使用Web服務,您必須在您的Microsoft Dynamics AX程序中使用此代碼來啓用服務引用來構建和配置服務客戶端的實例。

// Retrieve the X++ type for the Bing service client object. 
ClrObject clientType = CLRInterop::getType("BingSearch.ServiceReferences.BingV2ServiceReference.BingPortTypeClient"); 

// Use the AifUtil class to create an instance of the service client object.  
BingSearch.ServiceReferences.BingV2ServiceReference.BingPortTypeClient client = AifUtil::CreateServiceClient(clientType); 
+0

我更新了我的問題作爲迴應。 – Daventrian

+0

也許你的問題是許可。也許'createServiceClient'嘗試創建文件但失敗。 AOS服務帳戶應該有權限嗎? –

1

配置文件中包含哪些更改?

如果是要修改的地址,您還可以根據您在Ax環境中存儲的參數,自行配置需要的配置文件並自行配置綁定。

例如,當您創建一個外部服務並且想從Ax調用它時,但DEV/TST/PRODUCTION具有不同的URL時。您可以在創建客戶端時指定此項,而不是在配置文件中添加地址和綁定信息。

下面是手動更改EndPoint並放入我們想要的值的一段代碼。 (你可以把值參數偏離航向,讓你可以爲每個環境設置此

static void Consume_GetZipCodePlaceNameWithEndPoint(Args _args) 
{ 
    DynamicsAxServices.WebServices.ZipCode.USAZipCodeServiceRef.PostalCodeServiceClient postalServiceClient; 
    DynamicsAxServices.WebServices.ZipCode.USAZipCodeServiceRef.PostalCodepostalCode; 
    System.ServiceModel.Description.ServiceEndpoint endPoint; 
    System.ServiceModel.EndpointAddress endPointAddress; 
    System.Exception exception; 
    System.Type type; 
    ; 

    try 
    { 
     // Get the .NET type of the client proxy 
     type = CLRInterop::getType('DynamicsAxServices.WebServices.ZipCode.USAZipCodeServiceRef.PostalCodeServiceClient'); 

     // Let AifUtil create the proxy client because it uses the VSAssemblies path for the config file 
     postalServiceClient = AifUtil::createServiceClient(type); 

     // Create and endpoint address, This should be a parameter stored in the system 
     endPointAddress = new System.ServiceModel.EndpointAddress("http://www.restfulwebservices.net/wcf/USAZipCodeService.svc"); 

     // Get the WCF endpoint 
     endPoint = postalServiceClient.get_Endpoint(); 

     // Set the endpoint address. 
     endPoint.set_Address(endPointAddress); 

     // Use the zipcode to find a place name 
     postalCode = postalServiceClient.GetPostCodeDetailByPostCode("10001"); // 10001 is New York 

     // Use the getAnyTypeForObject to marshal the System.String to an Ax anyType 
     // so that it can be used with info() 
     info(strFmt('%1', CLRInterop::getAnyTypeForObject(postalCode.get_PlaceName()))); 
    } 
    catch(Exception::CLRError) 
    { 
     // Get the .NET Type Exception 
     exception = CLRInterop::getLastException(); 

     // Go through the inner exceptions 
     while(exception) 
     { 
      // Print the exception to the infolog 
      info(CLRInterop::getAnyTypeForObject(exception.ToString())); 

      // Get the inner exception for more details 
      exception = exception.get_InnerException(); 
     } 
    } 
} 
1

在Visual Studio項目轉到app.config文件的屬性,並設置以下屬性:

  • 打造:內容
  • 副本出的文件夾:如果複製新

(不知道性能的翻譯是正確的BE因爲我有德語版...)

+0

這爲我們解決了!謝謝 –