When compiling a project with a Postsharp MethodInterceptionAspect, I get the following error:
Unhandled exception (postsharp-net40-x86-srv.exe release | .NET Framework 4.7.1): System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at ^nIsIyZ7TTJqY.GetKeyInfo(^8gP93Xsl\+Imn _0)
at ^Up6wxUIUnN6a.^3w8852HL()
at ^Up6wxUIUnN6a.^VfvrABjR()
at ^Up6wxUIUnN6a.^SkiT()
at ^Up6wxUIUnN6a.^8KD6D2SV(String _0)
at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute()
at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Sdk.Extensibility.Project.Execute()
at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
I'm not running Visual Studio (and do not want to) as admin.
This possible solution did not work:
https://stackoverflow.com/a/43182648/201019
When I do run VS ad admin, I have no issue.
I have tried changing the project targeting framework from 4.6.1 to 4.5.1 to no avail.
Related
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'm using EntityFramework version 6.1.3.
I copied migrate.exe from EntityFramework version 6.1.3 package tool folder to bin folder of my website.
My web site is compiled and published to production environment with x86 CPU and target framework 4.5.1
I run the following command:
D:\Sites\MatrixPortal\bin>migrate.exe
d:\sites\MatrixPortal\bin\MatrixPortal.BL.dll
/startUpDirectory="d:\Sites\MatrixPortal\bin"
/startUpConfigurationFile="d:\Sites\MatrixPortal\Web.config"
and i get the following error:
ERROR: Could not load file or assembly
'd:\sites\MatrixPortal\bin\MatrixPortal.BL' or one of its
dependencies. The given assembly name or codebase was invalid.
(Exception from HRESULT: 0x80131047)
EDIT:
when i try this:
migrate MatrixPortal.BL.dll /verbose
i get other error:
System.BadImageFormatException: Could not load file or assembly
'MatrixPortal.BL' or one of its dependencies. An attempt was made to
load a program with an incorrect format. File name: 'MatrixPortal.BL'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,
String codeBase, Evidence assemblySecurity, RuntimeAssembly
locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder,
Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) at
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr
pPrivHostBinder, Boolean forIntrospection) at
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection) at System.Reflection.Assembly.Load(String
assemblyString) at
System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly(String
name) at
System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
at
System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate
callBackDelegate) at
System.Data.Entity.Migrations.Console.Program.Run() at
System.Data.Entity.Migrations.Console.Program.Main(String[] args)
=== Pre-bind state information === LOG: DisplayName = MatrixPortal.BL (Partial) WRN: Partial binding information was supplied for an
assembly: WRN: Assembly Name: MatrixPortal.BL | Domain ID: 2 WRN: A
partial bind occurs when only part of the assembly display name is
provided. WRN: This might result in the binder loading an incorrect
assembly. WRN: It is recommended to provide a fully specified textual
identity for the assembly, WRN: that consists of the simple name,
version, culture, and public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///D:/Sites/MatrixPortal/bin/ LOG: Initial PrivatePath = NULL
Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089.
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
C:\Users\guy_b\AppData\Local\Temp\tmpC402.tmp LOG: Using host
configuration file: LOG: Using machine configuration file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Attempting
download of new URL
file:///D:/Sites/MatrixPortal/bin/MatrixPortal.BL.DLL. ERR: Failed to
complete setup of assembly (hr = 0x8007000b). Probing terminated.
ERROR: Could not load file or assembly 'MatrixPortal.BL' or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
also tried this:
http://www.azurefromthetrenches.com/command-line-entity-framework-code-first-migrations/
and created a file called Redirect.config with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0-6.1.3" newVersion="6.1.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
but got the same error as above :(
In my case I got the error because I wrote migrate .\MyAssembly.dll instead of migrate MyAssembly.dll.
See Common Problems documentation section.
SOLVED!
I've Published the web site project with x86 target cpu, and apparently it wasn't really x86, i don't know why, maybe a bug?
After changing Publish to any cpu it worked. i was able to run migrate.exe without an error using the following arguments:
migrate.exe MatrixPortal.BL.dll /verbose /startUpDataDirectory="D:\Sites\MatrixPortal" /startUpConfigurationFile="D:\Sites\MatrixPortal\Web.config"
I just created a new service fabric service that will periodically attempt to save some models to SQL Azure using Entity Framework and the Elastic Client Database library. I'm trying to model it as closely as I can to the SQL Azure Elastic Scale Client Library EF sample (Elastic DB Tools EF Sample). I'm at the point where I need to enable migrations, but when I run Enable-Migrations I'm getting the following error message. I'm using the ContextTypeName parameter since it sounded like it would be required if I'm going to eventually have different service fabric services targeting the same database with different models. Any suggestions?
PM> Enable-Migrations -ContextTypeName "ServiceHealth.DbService"
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is
not marked as serializable."
At C:\eNowCloud\eNow.MicroServices\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720 char:5
+ $domain.SetData('startUpProject', $startUpProject)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.
I have resolved the same exception issue by specifying -StartUpProjectName parameter of Enable-Migrations command to my .NET framework dll with the db context. The issue might be with the weird startup project - problem in .IsWebProject() (asp.core in my case). See more detail answer on Enable-Migrations Exception calling "SetData" with "2" argument(s).
If you are using visual studio 2019, when you want to add a new class library you face to kind of class library:
Class Library (.NET Standard)
Class Library (.NET Framework)
Well, I used to pick number1, but now I know I have made mistake.
The solution is to Pick number2.
Instead of Enable-Migrations Do this EntityFrameworkCore\Enable-Migrations
Use EntityFrameworkCore\ before any command.
PS: Using VisualStudio 2019
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
I am trying use a Word document from my application on a Windows 2008 server 64bit from my MVC 2 application. I encountered this error message:
System.UnauthorizedAccessException: Retrieving the COM class factory
for component with CLSID {000209FF-0000-0000-C000-000000000046} failed
due to the following error: 80070005 Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED)).
at
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
skipCheckThis, Boolean fillCache)
at
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean
fillCache)
at System.Activator.CreateInstance(Type type, Boolean
nonPublic).
I have tried all know solutions, but still cannot fix it.
First of all, please note that serverside office interop isn't
officially supported by Microsoft:
http://support.microsoft.com/kb/257757
Nevertheless I got a similar scenario running with power point and had to do the following steps to get rid of the error you describe:
Run Microsoft Management Console (mmc.exe)
Add Snap-In for "Component Services"
Search for Computers\My Computer\DCOM Config\Microsoft Office Power Point Slide\ (you may search for something that sounds correct for your word-scenario)
Open Properties > Tab "Security"
"Launch and Activation Permissions" > Edit ...
Add your application pool user to this list and allow "Local Launch" and "Local Activation"