I have problem with Google Analytics API .NET.
While connecting to GA via api at line
var certificate = new X509Certificate2(pathToPrivateKey, passToPrivateKey, X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmailAddress)
{
Scopes = scopes
}.FromCertificate(certificate));
It give below error
Message=The type initializer for 'Google.Apis.Http.ConfigurableMessageHandler' threw an exception.
Source=Google.Apis.Core
TypeName=Google.Apis.Http.ConfigurableMessageHandler
StackTrace:
at Google.Apis.Http.ConfigurableMessageHandler..ctor(HttpMessageHandler httpMessageHandler)
at Google.Apis.Http.HttpClientFactory.CreateHttpClient(CreateHttpClientArgs args) in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Core\Apis\Http\HttpClientFactory.cs:line 37
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor(Initializer initializer) in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\ServiceAccountCredential.cs:line 217
at ConsoleApplication3.Program.AuthenticationGA(String pathToPrivateKey, String serviceAccountEmailAddress, String passToPrivateKey) in C:\Documents and Settings\pivotaladmin.WA-PIV\my documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:line 30
at ConsoleApplication3.Program.Main(String[] args) in C:\Documents and Settings\pivotaladmin.WA-PIV\my documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:line 69
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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.FileLoadException
Message=Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Source=Google.Apis.Core
FileName=System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
FusionLog==== Pre-bind state information ===
Project type: Console app
.NET Framework 4.0
MS Visual Studio 2010 Express
Windows Server 2003
I tried the same code on Windows 7 and it works.
I have no idea what goes wrong.
Any idea?
It looks like your main problem is the inner exception you got:
InnerException: System.IO.FileLoadException
Message=Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies.
The good news is that you should just install the following patch: KB2468871, as suggested here:
Could not load file or assembly System, Version=2.0.5.0 in .NET 4 MVC 4 application
Related
I started programming with Visual Studio 2022 in Mac M1. I am developing an application with .net core 6 and initially I used to develop in Windows. I copied my project and started to work in VS 2022 Mac. While doing the DB Migration (Using dotnet CLI) I am getting error and it's getting failed due to NLog.config. I am using NLog for the logging functionality.
DataAccess layer and WepAPI are separate project in a solution.DBContextClass and migration scripts are present in DataAccess Layer and the connection string is present in WebAPI.
Error while doing the db migration:
Time Elapsed 00:00:01.65 Build succeeded. dotnet exec --depsfile
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.deps.json
--additionalprobingpath /Users/MASKED/.nuget/packages --runtimeconfig /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.runtimeconfig.json
/Users/MASKED/.dotnet/tools/.store/dotnet-ef/6.0.7/dotnet-ef/6.0.7/tools/net6.0/any/tools/netcoreapp2.0/any/ef.dll
database update -c ApplicationDbContext --assembly
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplication.DataAccess.dll
--project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/MyCoreApplication.DataAccess.csproj
--startup-assembly /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.dll
--startup-project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/MyCoreApplicationWebAPI.csproj
--project-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/
--root-namespace MyCoreApplication.DataAccess --language C# --framework net6.0 --nullable --working-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess
--verbose Using assembly 'MyCoreApplication.DataAccess'. Using startup assembly 'MyCoreApplicationWebAPI'. Using application base
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0'.
Using working directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI'.
Using root namespace 'MyCoreApplication.DataAccess'. Using project
directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/'.
Remaining arguments: . Finding DbContext classes... Finding
IDesignTimeDbContextFactory implementations... Finding application
service provider in assembly 'MyCoreApplicationWebAPI'... Finding
Microsoft.Extensions.Hosting service provider... Using environment
'Development'. NLog.NLogConfigurationException: Exception when loading
configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
---> System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Xml.XmlTextReaderImpl.Read() at
System.Xml.XmlReader.MoveToContent() at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) --- End of inner exception
stack trace --- at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) at
NLog.Config.XmlLoggingConfiguration..ctor(XmlReader reader, String
fileName, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfiguration(XmlReader
xmlReader, String configFile, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory
logFactory, String configFile) at
NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory
logFactory, String configFile, LoggingConfiguration& config) at
NLog.Config.LoggingConfigurationFileLoader.Load(LogFactory logFactory,
String filename) at
NLog.Config.LoggingConfigurationWatchableFileLoader.Load(LogFactory
logFactory, String filename) at
NLog.LogFactory.LoadConfiguration(String configFile, Boolean optional)
at NLog.LogFactory.LoadConfiguration(String configFile) at
NLog.LogManager.LoadConfiguration(String configFile) at
Program.$(String[] args) in
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/Program.cs:line
25
--- End of stack trace from previous location --- at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.CreateHost()
at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass10_0.b__0(String[]
args) at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass13_0.b__3(String[]
args) at
Microsoft.EntityFrameworkCore.Design.Internal.AppServiceProviderFactory.CreateFromHosting(String[]
args)
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error:
Exception when loading configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
No application service provider was found. Finding DbContext classes
in the project... Found DbContext 'ApplicationDbContext'.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to
create an object of type 'ApplicationDbContext'. For the different
patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728 --->
System.InvalidOperationException: Unable to resolve service for type
'Microsoft.EntityFrameworkCore.DbContextOptions1[MyCoreApplication.DataAccess.Data.ApplicationDbContext]' while attempting to activate 'MyCoreApplication.DataAccess.Data.ApplicationDbContext'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1
factory) at
Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String
contextType) at
Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action
action)
Unable to create an object of type 'ApplicationDbContext'. For the different patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728
I updated from EF6.2 to EF6.4 and I encountered this exception chain:
[VerificationException: Operation could destabilize the runtime.]
System.Data.Entity.Core.Metadata.Edm.FacetDescription.Validate(String declaringTypeName) +70
System.Data.Entity.Core.Metadata.Edm.FacetDescription..ctor(String facetName, EdmType facetType, Nullable`1 minValue, Nullable`1 maxValue, Object defaultValue, Boolean isConstant, String declaringTypeName) +103
System.Data.Entity.Core.SchemaObjectModel.FacetDescriptionElement.CreateAndValidateFacetDescription(String declaringTypeName) +115
System.Data.Entity.Core.SchemaObjectModel.TypeElement.ResolveTopLevelNames() +119
System.Data.Entity.Core.SchemaObjectModel.Schema.ResolveTopLevelNames() +206
System.Data.Entity.Core.SchemaObjectModel.Schema.Resolve() +16
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) +554
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection) +156
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.LoadProviderManifest(XmlReader xmlReader, String location, Boolean checkForSystemNamespace, Schema& schema) +151
System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest.Load(XmlReader reader) +75
System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest..ctor(XmlReader reader) +116
System.Data.Entity.SqlServer.SqlProviderManifest..ctor(String manifestToken) +37
System.Data.Entity.SqlServer.<>c.<GetDbProviderManifest>b__29_0(String s) +25
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +65
System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifest(String versionHint) +125
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest(String manifestToken) +55
[ProviderIncompatibleException: The provider did not return a ProviderManifest instance.]
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest(String manifestToken) +187
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +119
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +43
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +159
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +124
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +678
System.Data.Entity.Internal.InternalContext.Initialize() +20
Website.Db.Context..ctor(DbConnection Connection) in Context.vb:15
Website._Default.GetNewsItems() in Default.aspx.vb:13
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +191
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
lambda_method(Closure , MethodInfo , Object , Object[] ) +39
System.Web.UI.WebControls.ModelDataSourceView.InvokeMethod(ModelDataSourceMethod method, Boolean isAsyncMethod) +326
System.Web.UI.WebControls.ModelDataSourceView.InvokeMethod(ModelDataSourceMethod method) +7
System.Web.UI.WebControls.ModelDataSourceView.GetSelectMethodResult(DataSourceSelectArguments arguments) +68
System.Web.UI.WebControls.ModelDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +14
System.Web.UI.WebControls.Repeater.GetData() +233
System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +207
System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +62
System.Web.UI.WebControls.Repeater.DataBind() +131
System.Web.UI.WebControls.Repeater.EnsureDataBound() +114
System.Web.UI.WebControls.Repeater.OnPreRender(EventArgs e) +16
System.Web.UI.Control.PreRenderRecursiveInternal() +166
System.Web.UI.Control.PreRenderRecursiveInternal() +236
System.Web.UI.Control.PreRenderRecursiveInternal() +236
System.Web.UI.Control.PreRenderRecursiveInternal() +236
System.Web.UI.Control.PreRenderRecursiveInternal() +236
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4722
Here's line 15 of Context.vb:
Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of Context, Migrations.Configuration))
A pretty straightforward database call, I'd say.
However, when I bumped back down to EF6.2, the error stopped.
I'm finding plenty of references to the individual exceptions here on SO, but nothing I've found so far quite fits the context of the combination of the three taken together with what the code is doing (general database access).
Do I need to alter my DAL code somehow in order to accommodate the EF6.4 update? Were there some breaking changes?
--EDIT--
Running locally under an explicit setting of Medium Trust, I get a different chain:
[PolicyException: Execution permission cannot be acquired.]
System.Security.CodeAccessSecurityEngine.TryResolveGrantSet(Evidence evidence, PermissionSet& grantSet) +14092083
System.Security.CodeAccessSecurityEngine.ResolveGrantSet(Evidence evidence, Int32& specialFlags, Boolean checkExecutionPermission) +60
[FileLoadException: Could not load file or assembly 'Microsoft.WebTools.BrowserLink.Runtime, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. PolicyException thrown. (Exception from HRESULT: 0x80131416)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +176
System.Reflection.Assembly.LoadFrom(String assemblyFile) +53
Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.GetRuntimeAssemblyFromSetupConfiguration(Assembly& runtime) +27
Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.LoadRuntime() +26
Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.PreApplicationStart() +45
[InvalidOperationException: The pre-application start initialization method PreApplicationStart on type Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader threw an exception with the following error message: Could not load file or assembly 'Microsoft.WebTools.BrowserLink.Runtime, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. PolicyException thrown. (Exception from HRESULT: 0x80131416).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +919
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +172
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854
[HttpException (0x80004005): The pre-application start initialization method PreApplicationStart on type Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader threw an exception with the following error message: Could not load file or assembly 'Microsoft.WebTools.BrowserLink.Runtime, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. PolicyException thrown. (Exception from HRESULT: 0x80131416).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724
This occurs under both EF6.2 and EF6.4.
If this is occurring on your remote deployment and not your local development environment after upgrading the EF version then I would suspect there is an issue with the deployment process.
Check the web.config in the deployed build to ensure that there are no EF-related runtime version dependency version overrides. (EntityFramework.dll and EntityFramework.SqlServer.dll)
Check the EntityFramework.dll assembly version between the deployed file on the remote server and your working local instance.
Copy the deployment from the remote server into a local folder, point IIS at it and then hook VS up running your project using Attach to Process on w3wp.exe. Set a breakpoint somewhere in the code and check that it remains a "hot" hit-able breakpoint and not an inactive one stating something along the lines of "The breakpoint will not currently be hit. The source line does not match..." This would indicate that the deployed code does not reflect a current, complete rebuild of what you are running in VS.
If you are using an automated build:
Check that dependency DLLs are not being checked in and that the build machine is actively resolving NuGet packages properly.
Check your references for EF, both before you upgrade the EF version (Source control revert all changes, use what was last built and deployed) Under the project explorer under References, select EntityFramework and check the path listed. It should be pointing to:
{Your solution folder}\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll
If it is pointing to anything like a \bin\debug etc. folder, remove the reference and repair to point at the NuGet package.
If NuGet packages folder is checked in, make sure this folder is complete and up to date in source control. When checking in nuget folders (as opposed to package version locking) I find this needs to be done from Explorer / TFS as normal VS checkins won't include them in pending changes. (unlike /bin folder changes if you accommodate them.) package folder updates can be skipped when initial checkins were made but then things like .ignore files are added/updated causing newer .dll files not to be updated.
Check for any stale or mismatched project files (.csproj/.vbproj) in your local environment vs. what is in source control. Often these can get flagged at some point as "Excluded Files" resulting in the automated build using out of date references.
Have a check through these and see if that identifies anything.
I have been using the latest Xrm sdk to access the metadata of my company's dynamics 365 account. This has been working well for some time, however it has broken all of a sudden roughly 3 weeks ago. There has been no code changes. This only means something has changed in their side.
Following is the code that has been used and it is very simple. The only information I have got till now is that their Security Protocol has changed to Tls12 and therefore tried to set that info before Organization Service object is created like so
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
But that has no influence either.
var sc = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("soap-url-from-365-developer-resources"));
var cc = new ClientCredentials();
cc.UserName.UserName = "username";
cc.UserName.Password = "password";
var organizationServiceProxy = new OrganizationServiceProxy(sc, cc);
organizationServiceProxy.EnableProxyTypes();
RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest()
{
EntityFilters = EntityFilters.Attributes,
RetrieveAsIfPublished = true
};
try
{
using (var organizationServiceContext = new CrmOrganizationServiceContext(organizationServiceProxy))
{
RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)organizationServiceContext.Execute(request);
var entities = response.EntityMetadata
.Where(x => x.DisplayName.UserLocalizedLabel != null &&
!string.IsNullOrWhiteSpace(x.DisplayName.UserLocalizedLabel.Label)
)
.ToList();
}
}
catch (Exception ex)
{
Console.WriteLine("GetAllEntities {0}", ex.Message); }
The error during Execute is as follows
System.InvalidOperationException: Metadata contains a reference that cannot be resolved: 'https://macfar.crm4.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
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.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception 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)
--- End of inner exception 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 Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata(Type contractType, Uri serviceUri, Boolean checkForSecondary)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1..ctor(Uri serviceUri, Boolean checkForSecondary)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceConfiguration..ctor(Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
at Microsoft.Xrm.Sdk.Client.ServiceConfigurationFactory.CreateConfiguration[TService](Uri serviceUri, Boolean enableProxyTypes, Assembly assembly)
at Microsoft.Xrm.Sdk.Client.ServiceProxy`1..ctor(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials)
I have tried everything that comes up googling this error message, however in vain. Therefore any help to work around this issue is greatly appreciated
There have been quite a few changes in the SDK compatibility in the last year.
You will need to make sure you have the right SDK version to match your .Net Framework and CRM versions.
Dynamics 365 SDK Backwards Compatibility
With the deprecation of Azure Access Control Service (ACS), we have to
modify our SDK authentication code by removing all references to ACS.
Effective from versions Microsoft Dynamics CRM Online 2016 Update 1
(v8.1.1) and Microsoft Dynamics 365 (v8.2), we removed Live ID support
and ACS dependencies on the server-side.
We also removed Microsoft.Xrm.Client from the CRM 2016 (8.x) SDK
client because it was not compliant with the OAuth changes, and
replaced it with Microsoft.Xrm.Tooling.Connector. You can use the
current Microsoft Dynamics 365 Software Development Kit (SDK) to
access Microsoft Dynamics CRM back to version 6.x for both auth and
messaging.
When upgrading to Dynamics 365, make sure you use the latest Microsoft
Dynamics 365 Software Development Kit (SDK). The following outlines
the current supported matrix for other SDK clients:
I'm trying to add Photon Voice to my Unity app for Windows 10, but I'm getting an error when I try to build the app from Visual Studio.
System.Exception: Exception while processing UnityVoiceFrontend UnityVoiceFrontend PhotonVoiceNetwork::client, error Failed to resolve assembly: 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
at Unity.Serialization.Weaver.MethodEmitterBase.WillUnitySerialize(FieldDefinition fieldDefinition)
at Unity.Serialization.Weaver.SerializeMethodEmitterBase.ShouldProcess(FieldDefinition fieldDefinition)
at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Unity.Serialization.Weaver.MethodEmitterBase.EmitMethodBody()
at Unity.Serialization.Weaver.MethodEmitterBase.CreateMethodDef(String methodName)
at Unity.Serialization.Weaver.SerializeMethodEmitter.SerializeMethodDefinitionFor(TypeDefinition typeDef, SerializationBridgeProvider serializationBridgeProvider)
at Unity.Serialization.Weaver.SerializationWeaver.AddSerializeMethod()
at Unity.Serialization.Weaver.SerializationWeaver.Weave()
at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition, ReaderParameters readerParameters)
at usw.Weaver.Weave()
at usw.Program.RunProgram(ConversionOptions options)
at usw.Program.Main(String[] args)
Am I missing something or did I not do the set up correctly?
I followed the instructions here
I have an app. I'm working on which self-hosts WebApi. It can run as either a command-line app, or as a Windows service. It's compiled using the .NET 4.5 runtimes.
When I run it on my Windows 7 dev. machine, it works fine.
When I deploy and run as a command-line app on my Windows 2012 server machine, it fails with the exception:
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec
t[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
at Owin.Loader.DefaultLoader.<>c__DisplayClass12.<MakeDelegate>b__b(IAppBuild
er builder)
at Owin.Loader.DefaultLoader.<>c__DisplayClass1.<LoadImplementation>b__0(IApp
Builder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext contex
t)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions opt
ions)
at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider service
s, StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options)
My code does this:
url = "http://localhost:5000";
_app = WebApp.Start<WebAppConfiguration>(url);
And the WebAppConfiguration class looks like this:
public class WebAppConfiguration : HttpConfiguration
{
public void Configuration(IAppBuilders app)
{
ConfigureRoutes();
ConfigureJsonSerialization();
// This line throws the exception:
app.UseWebApi(this);
}
}
I did some searching and it sounded like I needed to reserve the port using NETSH, so this is what I did from an Admin command prompt:
netsh http add urlacl url=http://localhost:5000/ user=Everyone listen=yes delegate=yes
Unfortunately, I'm still getting the exception. Is there some other step I need to do to get this to work under Windows Server 2012?
EDIT:
The inner exception (which I didn't think to log) contained a much more helpful error. It turns out I was missing an assembly binding entry for Microsoft.Owin in my .config file for Owin. This was in my dev. version but didn't make it into the version on my server.