kip-dk / dynamics-plugin

Dynamics 365 plugin template project
10 stars 9 forks source link

unable to install with Dynamics CRM 2016 on prem #3

Open charliechen179 opened 2 years ago

charliechen179 commented 2 years ago

When I run the generate.cmd, I get this:

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to login to Dynamics CRM, Error was : Metadata contains a reference that cannot be resolved: 'http://22222/Telecom/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. Source : System.ServiceModel Method : Retrieve Date : 3/11/2022 Time : 7:18:34 AM Error : Metadata contains a reference that cannot be resolved: 'http://222222/Telecom/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. Stack Trace : at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper) at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState) at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(MetadataRetriever retriever) at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(Uri address, MetadataExchangeClientMode mode) at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata(Type contractType, Uri serviceUri, Boolean checkForSecondary) at Microsoft.Xrm.Sdk.Client.ServiceConfiguration1..ctor(Uri serviceUri, Boolean checkForSecondary) at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration..ctor(Uri serviceUri, Boolean enableProxyTypes, Assembly assembly) at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateManagement[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly) at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateManagement[TService](Uri serviceUri) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.CreateAndAuthenticateProxy[T](IServiceManagement1 servicecfg, Uri ServiceUri, Uri homeRealm, ClientCredentials userCredentials, ClientCredentials deviceCredentials, String LogString, CrmLogEntry logSink) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.ConnectAndInitCrmOrgService(OrganizationDetail orgdata, Boolean IsOnPrem, Uri homeRealmUri) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DoDirectLogin(Boolean IsOnPrem) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service()

Inner Exception Level 1 : Source : System Method : GetResponse Date : 3/11/2022 Time : 7:18:34 AM Error : The remote name could not be resolved: '04506puld' Stack Trace : at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Description.MetadataExchangeClient.MetadataLocationRetriever.DownloadMetadata(TimeoutHelper timeoutHelper) at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM Source : Not Provided Method : Not Provided Date : 3/11/2022 Time : 7:18:34 AM Error : Unable to Login to Dynamics CRM Stack Trace : Not Provided

Unable to login to Dynamics CRM, Error was : Metadata contains a reference that cannot be resolved: 'http://222222/Telecom/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. Metadata contains a reference that cannot be resolved: 'http://222222/Telecom/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. => The remote name could not be resolved: '04506puld'Unable to Login to Dynamics CRM Unable to Login to Dynamics CRM

Exiting program with exception: Connection to CRM is not established. Aborting process. CrmSvcUtil Error: 2 : Exiting program with exit code 2 due to exception : System.Exception: Connection to CRM is not established. Aborting process. at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service) at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args) CrmSvcUtil Error: 2 : ===== DETAIL ====== CrmSvcUtil Error: 2 : Source : CrmSvcUtil Method : LoadMetadata Date : 7:18:34 AM Time : 3/11/2022 Error : Connection to CRM is not established. Aborting process. Stack Trace : at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service) at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)

kip-dk commented 2 years ago

Hi Charlie, unless your server is called 222222 and is listening on http you have setup the connection string in the generator tool wrongly. Here is a connection string working on my onprem env:

..\bin\coretools\CrmSvcUtil.exe "/connectionstring:AuthType=AD;Url=http://my-server-name/NNNN;" "/out:Context.design.cs" "/ServiceContextName:ContextService" "/namespace:MyCustomersName.Plugin.Entities" "/codewriterfilter:Kipon.Xrm.Tools.CodeWriter.CodeWriterFilter,Kipon.Xrm.Tools" "/codecustomization:Kipon.Xrm.Tools.CodeWriter.PluginCustomizeCodeDomService,Kipon.Xrm.Tools" /generateActions

This connection string is using windows auth. and the user you are logged in as in the command prompt must be a windows domain user that has admin rights on the crm instance. You must replace my-server-name with the name of your server and NNNN with the instance on the server to connect to.

if you browse http://my-server-name/NNNN in a browser, CRM should show up. That way you can verify that you got the url right.

You can follow documentation on this site also:

https://kipon.dk/solidplugin

If this does not solve the problem, you should start resolve why CrmSvcUtil.exe is not working. That tools is not a kipon tool, it is a microsoft standard tool for generating early bound entities. The version of the SDK you are using might be too high for a Dynamics CRM 2016. (that is problerbly a sdk version 8.2 or even earlier), If so, try to downgrade to an earlier version of the Microsoft.CrmSdk.CoreTools. Kipon.Solid.plugin does work with earlier version of Dynamics 365.

charliechen179 commented 2 years ago

Thanks Kip. I try to use 8.2 tooling but still getting error. Kipon package is only compatible with version 9 and above. It won't install if CRM nuget is below version 9.

Error with version 9 tooling: C:\Users{user}\source\repos\CSharpPluginProject1\HOT.CRM.Plugins\Entities>..\bin\coretools\CrmSvcUtil.exe "/connectionstring:AuthType=AD;Url=http://{server}/{instance}" "/out:Context.design.cs" "/ServiceContextName: ContextService" "/namespace:HOT.CRM.Plugins.Entities" "/codewriterfilter:Kipon.Xrm.Tools.CodeWriter.CodeWriterFilter,Kipon.Xrm.Tools" "/codecustomization:Kipon.Xrm.Tools.CodeWriter.PluginCustomizeCodeDomService,Kipon.Xrm.Tools" /generateActions CrmSvcUtil : CRM Service Utility [Version 9.1.0.82] c 2020 Microsoft Corporation. All rights reserved

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to login to Dynamics CRM, Error was : The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. Source : mscorlib Method : HandleReturnMessage Date : 3/13/2022 Time : 1:29:21 PM Error : The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. Stack Trace : Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.RefreshInstanceDetails(IOrganizationService crmService, Uri uriOfInstance) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.DoDirectLogin(Boolean IsOnPrem) at Microsoft.Xrm.Tooling.Connector.CrmWebSvc.InitCRM2011Service()

Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM Source : Not Provided Method : Not Provided Date : 3/13/2022 Time : 1:29:21 PM Error : Unable to Login to Dynamics CRM Stack Trace : Not Provided

Unable to login to Dynamics CRM, Error was : The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.Unable to Login to Dynamics CRM Unable to Login to Dynamics CRM

Exiting program with exception: Connection to CRM is not established. Aborting process. CrmSvcUtil Error: 2 : Exiting program with exit code 2 due to exception : System.Exception: Connection to CRM is not established. Aborting process. at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service) at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args) CrmSvcUtil Error: 2 : ===== DETAIL ====== CrmSvcUtil Error: 2 : Source : CrmSvcUtil Method : LoadMetadata Date : 1:29:21 PM Time : 3/13/2022 Error : Connection to CRM is not established. Aborting process. Stack Trace : at Microsoft.Crm.Services.Utility.SdkMetadataProviderService.LoadMetadata(IServiceProvider service) at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)

charliechen179 commented 2 years ago

If I use version 8.2 coretools, I have error with this

C:\Users{user}\source\repos\CSharpPluginProject1\HOT.CRM.Plugins\Entities>..\bin\coretools\CrmSvcUtil.exe "/connectionstring:AuthType=AD;Url=http://{server}/{instance}" "/out:Context.design.cs" "/ServiceContextName: ContextService" "/namespace:HOT.CRM.Plugins.Entities" "/codewriterfilter:Kipon.Xrm.Tools.CodeWriter.CodeWriterFilter,Kipon.Xrm.Tools" "/codecustomization:Kipon.Xrm.Tools.CodeWriter.PluginCustomizeCodeDomService,Kipon.Xrm.Tools" /generateActions CrmSvcUtil : CRM Service Utility [Version 8.2.1.8676] c 2015 Microsoft Corporation. All rights reserved

Exiting program with exception: Could not load file or assembly 'CrmSvcUtil, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) CrmSvcUtil Error: 2 : Exiting program with exit code 2 due to exception : System.IO.FileLoadException: Could not load file or assembly 'CrmSvcUtil, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'CrmSvcUtil, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.Type.GetType(String typeName, Boolean throwOnError) at Microsoft.Crm.Services.Utility.ServiceFactory.CreateInstance[TIService](TIService defaultServiceInstance, String parameterValue, CrmSvcUtilParameters parameters) at Microsoft.Crm.Services.Utility.ServiceProvider.InitializeServices(CrmSvcUtilParameters parameters) at Microsoft.Crm.Services.Utility.CrmSvcUtil.get_ServiceProvider() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

CrmSvcUtil Error: 2 : ===== DETAIL ====== CrmSvcUtil Error: 2 : Source : mscorlib Method : GetTypeByName Date : 1:32:40 PM Time : 3/13/2022 Error : Could not load file or assembly 'CrmSvcUtil, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Stack Trace : at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.Type.GetType(String typeName, Boolean throwOnError) at Microsoft.Crm.Services.Utility.ServiceFactory.CreateInstance[TIService](TIService defaultServiceInstance, String parameterValue, CrmSvcUtilParameters parameters) at Microsoft.Crm.Services.Utility.ServiceProvider.InitializeServices(CrmSvcUtilParameters parameters) at Microsoft.Crm.Services.Utility.CrmSvcUtil.get_ServiceProvider() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run() at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)

kip-dk commented 2 years ago

Hi Charlie

we are ending up in a catch 22. The crmsvcutil kipon extension has been compiled with a version 9.x of the crmsvcutil, so when running with an older version of crmsvcutil, it tries to load the kipon.xrm.tools, that has a reference to crmsvcutil version 9, and that assembly is for good reason not found in the exe directory because you downgraded.

CRM 2016 is supported by microsoft until jan 2026, so i have decided to create a parralel build for CRM 20216 users. I will update this issue when done.

charliechen179 commented 2 years ago

Thanks Kip. Much appreciated. Do you open source the project by any chance?

kip-dk commented 2 years ago

All kipon solid plugin code is open source under MIT. Only the documentation on kipon.dk website is private and restricted.

charliechen179 commented 2 years ago

Great! How about the Nuget package? Is it open-sourced as well? Thanks!

kip-dk commented 2 years ago

Yes, i expect to release a kipon.solid.plugin.2016 (nuget package) end of this week (sometimes sunday). The only difference from kipon.solid.plugin is that is is binded with the latest possible std. xrm libraries for version 8.2 of dynamics. I regards to source code and more, - it is a simple branch of the existing git source that is binded with older version of the microsoft SDK. The licens of the kipon tools is still MIT for this part of the sourcecode as well.

kip-dk commented 2 years ago

After spending several days trying to get a library up running for CRM 2016 I give up. It is not worth the effort. You should upgrade your CRM to the newest version of Dynamics 365 instead. It is a pretty straight forward task to perform.

I did add a CRM2016 folder in the source control, with all libraries downgraded to 8.2, and removed all features related to version 9, and that code compiles and are fine.

But when i try to generate early bound entities even without any kipon extensions, i get "Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=9.0.0.0,". I simply don't get it. it must be because i am running on a machine that does have CRM 9.1 installed, and for whatever reason the tool tries to load assemblies related to that version. The is the behavior even using crmsvcutil out-of-box, so the behavior is not related to the Kipon.Solid.Plugin framework.

Spinning up infrastructure to have a clean 2016 installation is simply to much of an effort for now. Feel free to try for the source and see if you can get the 2016 folder to do what it is suppose to do.

charliechen179 commented 2 years ago

Thank you so much for the effort and all the details. I will give a try and let you know how it goes.

kip-dk commented 2 years ago

It is aways when i give up, things start to work i am able to generate entities now ,,, so hold on ... i might be able to get it all to work anyway

kip-dk commented 2 years ago

I needed to add assembly reference maps to crmsvcutil folder downgrading all xrm tools from 9.0.0 8.0.0 now the genrate entities works locally for me

charliechen179 commented 2 years ago

You made it. Great!

kip-dk commented 2 years ago

New nuget package for Dynamics CRM 2016 has been released:

CRM 2016 nuget package

Alongside we also released a version of the fake unit test package:

CRM 2016 unit test fake context

All related code is hosted in the subfolder CRM2016 of this project and is released under the same MIT license

Happy plugincoding,

charliechen179 commented 2 years ago

Thank you very much. Great work!