Calling Dynamics Crm Online XrmServiceContext results in an exception - dynamics-crm

I just registered for an online 365 trial version.
I copy-pasted the Walkthrough sample code appearing here, and changed the Url, Username and Password values inside the App.config, so that they have the relevant values.
However, I get an exception when calling xrm.SaveChanges():
Content of exception:
An unhandled exception of type
'Microsoft.Xrm.Sdk.SaveChangesException' occurred in
Microsoft.Xrm.Sdk.dll
Content of Message:
An unsecured or incorrectly secured fault was received from the other
party. See the inner FaultException for the fault code and detail.
Content of Inner Exception:
Code: {System.ServiceModel.FaultCode}, Message: Invalid Request
Stack trace:
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions
options)
at
Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges()
at CRMSimpleConsole1.Program.Main(String[] args) in
C:\Users\home\documents\visual studio
2015\Projects\CRMSimpleConsole1\CRMSimpleConsole1\Program.cs:line 32
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String
assemblyFile, Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at
System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart() I also get an exception
when calling xrm.Create(): An unhandled exception of type
'System.ServiceModel.Security.MessageSecurityException' occurred in
mscorlib.dll
Note that the same happens for any call to the service (e.g., xrm.Create().
I searched for this on the web, and people say it is caused because of wrong time sync. Well, at least in the CRM Settings area, the time zone is correct, so I don't what to do.

The Xrm.Client is deprecated and as others have mentioned, the way to connect via a console app is CrmServiceClient, which is in the Microsoft.Xrm.Tooling.Connector library.
Using NuGet you can get the Microsoft.CrmSdk.XrmTooling.CoreAssembly package and you'll be off to the races.
Here are a couple other helpful links:
Build Windows client applications using the XRM tools
Sample: Quick start for XRM Tooling API
And here's a connection string example for Dyn365 online:
<add name="dev26" connectionString="Url=https://dev26.crm.dynamics.com; Username=user#dev26.onmicrosoft.com; Password=Pass; AuthType=Office365" />

From the connection string given in Microsoft's walkthrough, you must also
remove Domain=CONTOSO
add AuthType=Office365

Related

ARR module related error logged in 'Event Viewer'

We have an issue on the production site and it throws 500 error. When I checked the 'Event Viewer', I saw the below error logged:-
The description for Event ID 11 from source Microsoft-Windows-IIS-IISManager cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
IISMANAGER_MODULE_INITIALIZATION_THREW_EXCEPTION
The Initialize method for module "Microsoft.Web.Management.WebFarm.WebFarmModule, Microsoft.Web.Management.WebFarmClient, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" of type "WebFarmFramework" threw an exception.
Exception:System.IO.FileNotFoundException: Could not find file 'Microsoft.Web.Management.WebFarmClient.resources'.
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at Microsoft.Web.Management.WebFarm.WebFarmModule.Initialize(IServiceProvider serviceProvider, ModuleInfo moduleInfo)
at Microsoft.Web.Management.Client.Connection.Initialize(WebManagementInfo webManagementInfo)
Process:InetMgr
The version details are:-
IIS versoin 8.5.9600
ARR 3.0.1750
WebFarm Framework: 1.1.0490
I tried re-installing the ARR module on the server but I do not see the 'Server Farms' node in IIS even after installation.
Can anyone please help?
Thank you
The exception seems to imply that the module hasn't been properly installed. You can install it via the Web Platform Installer, or if your Installer had become corrupt, locate the file on a known good installation and copy it over.
From memory the module is located in C:\windows\system32\inetsrv

"XamlCTask" task failed unexpectedly" error when building with the new Xamarin Forms

After I've updated to the latest Xamarin.Forms (2.3.4.224) I keep getting build errors. anyone knows what this could be?
I suspect it might have to do with the new behavior changes they have introduced with the new version regarding Attached Properties (but I don't know that that means)
more info here https://forums.xamarin.com/discussion/92455/xamarin-forms-2-3-4-224
and here is my build log
Error The "XamlCTask" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added.
Server stack trace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader)
at Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested)
at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader)
at Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested)
at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader)
at Xamarin.Forms.Xaml.XamlParser.ReadNode(XmlReader reader, Boolean nested)
at Xamarin.Forms.Xaml.XamlParser.ParseXamlElementFor(IElementNode node, XmlReader reader)
at Xamarin.Forms.Xaml.XamlParser.ParseXaml(RootNode rootNode, XmlReader reader)
at Xamarin.Forms.Build.Tasks.XamlTask.ParseXaml(Stream stream, TypeReference typeReference)
at Xamarin.Forms.Build.Tasks.XamlCTask.Execute(IList`1& thrownExceptions)
at Xamarin.Forms.Build.Tasks.XamlTask.Execute()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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.Build.Framework.ITask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Shared
I'm not exactly sure if this is the same case, but I ran into the same problem.
I had different version of Forms installed. After I updated all nuget packages and deleted all obj and bin folders I was able to make a build without errors.
Clean your solution and close your Visual Studio 2017. The error will gone when you open it again.

Cannot insert duplicate key in CRM 2011 Plugin import?

I have exported the plugins from prod server, and getting the following error message when importing into the test server.
Unhandled Exception: System.Web.Services.Protocols.SoapException:
Server was unable to process request.
Detail:
0x80040237
Cannot insert duplicate key.
Platform
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at PluginRegistrationTool.CrmSdk.CrmService.Create(BusinessEntity
entity)
at
PluginRegistrationTool.RegistrationHelper.RegisterAssembly(CrmOrganization
org, String pathToAssembly, CrmPluginAssembly assembly)
at
PluginRegistrationTool.ImportExport.ImportSolution(CrmOrganization
org, ICollection1 assemblies, ICollection1 checkedTreeNodes,
IDictionary`2 pathList)
at PluginRegistrationTool.ImportExportForm.btnExecute_Click(Object
sender, EventArgs e)
On your test server check if plugins/steps/images by the same name are already existing. If yes, then delete them first before attempting the import.
I would recommend that you delete all registered plungins first before attempting to import.
When you create a new plugin Visual Studio will automatically create the step/class name for you based on the Pipeline Stage (Pre-Validation, Pre-Operation, Post-Operation) the Primary Entity (Contact, Organization) and the Message (Create, Update, etc) For example, PostContactUpdate or PreOrganizationUpdate, so if you happen to be making another plugin with same message, pipeline stage and primary entity and you accepted the default class names that could explain why you are getting the error. Changing the class name and redeploying should fix it for you.

How to use the dbDacFx Provider in Web Deploy for a delta db deployment

I'm struggling to the maximum trying to get DB deployment done from a remote client.
Let me fire you some details.
Problem
System.Runtime.Serialization.SerializationException: Member 'ClassName' was not found.
Occurs during a publish to the remote IIS server from Visual studio 2012.
Server
Windows Server 2008 R2
IIS 7.5
SQL SERVER 2012 Express
What goes wrong
I select publish on my web application (within visual studio 2012 / windows 8 pro)
I publish my web application no problem to my remote web server (confirmed web page deployed and is accessible from www).
I open publish again, this time selecting DB publish.
Exception occurs on the server, message is propagated to client.
=> application publishing is fine, just not DB.
What i've tried
Every guide, faq, step by step guide I can find online.
I've uninstalled and re-installed all the deployment packages for IIS (DAC framework, Web Deployment 3, Web deployment tools 2.1 - server)
Re install all client side DAC libraries on client.
Uninstall, re-install, rebooting, punching my keyboard and monitor (not my main DELL ultrasharp 24..just my 21" acer thing).
Nothing is helping (except the keyboard punching..which made me feel slightly relieved), i've just spent 10 hours, no joy. Service Delegation entries are setup for the correct DAC based provider.
Seems to be some fundamental problem, based on my understanding, an assembly is being reflected on, and is expecting to have a member called 'ClassName'..but it doesn't exist..i.e....the assembly must not be in sync with the consumer.
But there are no clear guidelines on line to confirm/ diagnose this..and nothing in the exception log except for this error (see below).
I've found a similar post on here with the same exception message, except the guys suggestions didn't help for me at all - tried them.
Please help, i've turned to chocolate biscuits and plain hambugers to drown out the pain...i'll need to drown myself again tomorrow at the gym (this time in sweat).
Thank you,
Karl
A tracing deployment agent exception occurred that was propagated to the client. Request ID '7dd5089d-4e51-4f27-aecc-c8044754a01e'. Request Timestamp: '10/11/2012 8:55:08 PM'. Error Details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Serialization.SerializationException: Member 'ClassName' was not found.
at System.Runtime.Serialization.SerializationInfo.GetElement(String name, Type& foundType)
at System.Runtime.Serialization.SerializationInfo.GetString(String name)
at System.Exception..ctor(SerializationInfo info, StreamingContext context)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at Microsoft.Web.Deployment.Base64EncodingHelper.DeserializeHelper(BinaryFormatter formatter, Byte[] buffer)
at Microsoft.Web.Deployment.Base64EncodingHelper.Deserialize(String str, Exception& handledException)
at Microsoft.Web.Deployment.SerializationHelper.Deserialize(String str)
at Microsoft.Web.Deployment.SqlDacPacProvider.ProcessExeOutput()
at Microsoft.Web.Deployment.SqlDacPacProvider.RunExecutableAsync(String exeName, String arguments, Int32 waitInterval, Int32 retryAttempts)
at Microsoft.Web.Deployment.SqlDacPacProvider.Add(DeploymentObject source, Boolean whatIf)
at Microsoft.Web.Deployment.DeploymentObject.Add(DeploymentObject source, DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAdd(DeploymentObject destObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable1 syncPassId)
at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable1 passId)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)
at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)

Properly Establishing an ApplicationEndpoint in UCMA 3.0

I've been struggling with getting an application endpoint working on UCMA 3.0. I am trying to run an application on a server separate from the Lync server which uses a registered ApplicationEndpoint to monitor presence and act as a bot which can send other users messages. I used to have my code working with a UserEndpoint (which was fine for monitoring presence), but did not have the capabilities to send IMs to other Lync users.
After searching the web, I'm finally at the point where I'm getting this error when running my code:
System.ArgumentException was unhandled
Message=An ApplicationEndpoint can be registered only if proxy and Multual Tls have been specified.
Source=Microsoft.Rtc.Collaboration
StackTrace:
at Microsoft.Rtc.Collaboration.ApplicationEndpoint..ctor(CollaborationPlatform platform, ApplicationEndpointSettings settings)
at Waldo.endpointHelper.CreateApplicationEndpoint(ApplicationEndpointSettings applicationEndpointSettings) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\endpointHelper.cs:line 117
at Waldo.endpointHelper.CreateEstablishedApplicationEndpoint(String endpointFriendlyName) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\endpointHelper.cs:line 228
at Waldo.waldoGrabPresence.Run() in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\waldoGrabPresence.cs:line 60
at Waldo.waldoGrabPresence.Main(String[] args) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\waldoGrabPresence.cs:line 42
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
After some searching, I followed the instructions here: http://blogs.claritycon.com/blogs/michael_greenlee/archive/2009/03/21/installing-a-certificate-for-ucma-v2-0-applications.aspx to import a certificate onto the server that I'm trying to run the application on, but to no avail.
So at this point, I think that there must be something wrong with how I'm setting up the ApplicationEndpointSettings, CollaberationPlatform or ApplicationEndpoint objects. Here's how I'm doing it:
ApplicationEndpointSettings settings = new ApplicationEndpointSettings(_ownerURIPrompt, _serverFQDNPrompt, _trustedPortPrompt);
ServerPlatformSettings settings = new ServerPlatformSettings(null, _serverFQDNPrompt, _trustedPortPrompt, _trustedApplicationGRUU);
_collabPlatform = new CollaborationPlatform(settings);
_applicationEndpoint = new ApplicationEndpoint(_collabPlatform, applicationEndpointSettings);
Does anyone see any problems with what I'm doing? Or, better yet, does anyone know of a blog that walks you through establishing an application endpoint in the situation I'm in? I work really well with tutorials or samples, but have not found one that seems to accomplish what I'm trying to do.
Thanks for the help!
The procedure to get a certificate in Lync is very different than OCS2007, and much easier. The link you posted is for UCMA2, and OCS, I believe. In Lync, it's basically two powershell statements.
1) Request-CSCertificate -Action new -Type default -CA -Verbose
2) Save the results of that statement, take the thumbprint, use it as the parameter to:
Set-CsCertificate -Type Default -Thumbprint XXXXXXXXXXXXXXXXXXXX
Installing UCMA 3.0 and Creating a Lync Server 2010 Trusted Application Pool
use powershell to provision a trusted application endpoint. The command to explore is new-trustedapplicationendpoint. The error you are getting is due to no trusted endpoint being registered, even though you may have your trusted application registered, it needs an endpoint to work and that endpoint must be first registered before you provision the platform.
The SDK CHM file should be your friend here! This section is about app activation and provisioning
Pass the certificate to the ServerPlatformSettings object, then it works. I had the similar problem, and the problem is resolved after using the ServerPlatformSettings(string applicationUserAgent, string localhost, int port, string gruu, string certificateIssuerName, byte[] certificateSerialNumber) constructor for the ServerPlatformSettings.

Resources