C# Dynamics AX 2012 DLL配置文件未更新
我们在AX环境中添加了一个C#项目。我们最近修改了app.config文件,清理并重建了项目,并将其部署到AOT。如果我进入SQLServerManagementStudio并查询VSAssemblys表,我可以看到相应的.dll和.dll.config文件。我转储了.dll.config的内容,并将其转换回文本,以确保表中的版本是最新的,并且是最新的 问题是当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应该被复制到项目输出中,但由于某些原因,它不是 我错过了什么C# Dynamics AX 2012 DLL配置文件未更新,c#,dll,app-config,axapta,dynamics-ax-2012,C#,Dll,App Config,Axapta,Dynamics Ax 2012,我们在AX环境中添加了一个C#项目。我们最近修改了app.config文件,清理并重建了项目,并将其部署到AOT。如果我进入SQLServerManagementStudio并查询VSAssemblys表,我可以看到相应的.dll和.dll.config文件。我转储了.dll.config的内容,并将其转换回文本,以确保表中的版本是最新的,并且是最新的 问题是当AOS重新启动时,.dll.config文件永远不会写入磁盘(C:\Program Files\Microsoft Dynamics A
简,谢谢你的帖子 我们正在以您引用的方式构建/配置服务:
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.
System.Reflection.targetingException:异常已由
调用的目标。-->System.InvalidOperationException:无法找到
应用程序配置文件C:\Users\\AppData\Local\Microsoft\
Dynamics Ax\VSAssemblies\OurService.dll.config。
OurService.dll.config文件位于AOT中,但在服务器或客户端启动时,它不会被写入磁盘。是否更改了全局app.config?不要 而是使用
AifUtil::CreateServiceClient
使项目配置文件可用
更改配置文件?这会起作用,但类库
配置文件存储在模型存储中,由
客户端/服务器。除非在AOT中更改,否则无法更改它
重建VisualStudio项目,此时客户端/服务器
将从模型库下载新版本。所以,你可以
将所有app.config设置复制/粘贴到AX32(serv.exe.config)中
在那里归档并更改它。那么你就不需要使用
aifUtil::createserviceclient。无论如何,这是非常不切实际的,
特别是在客户端运行的服务
从:
下面的示例代码显示了如何为Bing服务构造和配置服务客户端对象。要使用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);
配置文件中包含哪些更改 如果要修改的是地址,还可以不需要配置文件,并根据存储在Ax环境中的参数自行配置绑定
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();
}
}
}
例如,当您创建了一个外部服务并希望从Ax调用它时,但是DEV/TST/PRODUCTION有不同的URL。您可以在创建客户机时指定它,而不是在配置文件中添加地址和绑定信息
下面是一段代码,手动更改端点并输入我们想要的值。(您可以将参数中的值设置为偏离路线,以便可以针对每个环境进行设置
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();
}
}
}
在visual Studio项目中,转到
app.config
文件的属性并设置以下属性:
- 构建:内容
- 复制到输出文件夹:如果较新,则复制
(不确定属性的翻译是否正确,因为我有德语版本…可能您的问题是权限问题。可能
createServiceClient
尝试创建文件但失败。AOS服务帐户应该有权限吗?