currently making a small program by using WinForms and 7zip unpacker. To make it easier added reference to "SevenZipSharp.dll" everything work good, untill i wanted to publish(debug) project. When i move the ".exe" file in Desktop got error :
System.IO.FileNotFoundException: Could not load file or
assembly 'X' or one of its dependencies".
I embedded resource set in .dll file + Copy Local: set to true
How i can make this programs to work without .dll in Current directory.
EDIT
I did it by use
System.Reflections
Solution here
But i got now another problem with
System.TypeInitializationException: 'The type initializer for 'SevenZip.SevenZipLibraryManager' threw an exception.. ---> System.ArgumentException: Path has an illegal format
w System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
w System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
w System.IO.Path.InternalGetDirectoryName(String path)
w System.IO.Path.GetDirectoryName(String path)
w SevenZip.SevenZipLibraryManager..cctor()
--- End of inner exception stack trace ---
w SevenZip.SevenZipLibraryManager.SetLibraryPath(String libraryPath)
w SevenZip.SevenZipBase.SetLibraryPath(String libraryPath)
You would want to have the referenced libraries in the same folder or else you can also register them in GAC.
Related
I am trying to work some examples with the AWS CDK using C# as the language. My platform is Windows 10. Edit: I forgot to mention, I'm using a 64-bit Windows 10 and I have 16 GB of RAM.
I've followed the Getting Started instructions here: Getting Started With the AWS CDK, including making sure I have all the prerequisites.
I can create a project just fine, but when I try to use synth or deploy, it get the following:
Unhandled exception. Amazon.JSII.Runtime.JsiiException: Child process exited unexpectedly:
#
# Fatal process OOM in insufficient memory to create an Isolate
#
at Amazon.JSII.Runtime.Services.Runtime.ReadResponse()
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Hello()
at Amazon.JSII.Runtime.Services.ServiceContainer.BuildServiceProvider(ILoggerFactory loggerFactoryOverride)
at Amazon.JSII.Runtime.Services.ServiceContainer.<>c.<.cctor>b__8_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Amazon.JSII.Runtime.Services.ServiceContainer.get_ServiceProvider()
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase..ctor(Type nativeType, String fullyQualifiedName)
at Amazon.JSII.Runtime.Deputy.JsiiClassAttribute..ctor(Type nativeType, String fullyQualifiedName, String parametersJson)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
at Amazon.JSII.Runtime.ReflectionUtils.GetClassAttribute(Type type)
at Amazon.JSII.Runtime.Deputy.DeputyBase..ctor(DeputyProps props)
at Amazon.CDK.Construct..ctor(DeputyProps props)
at Amazon.CDK.App..ctor(IAppProps props)
at CdkHello.Program.Main(String[] args) in C:\VSTS\Sandbox\Hampson\cdk-hello\src\CdkHello\Program.cs:line 12
Subprocess exited with error 3762504530
Program.cs, line 12 is a generated line, unchanged from it's initial form.
I have searched repeatedly for this error, and all the search results point to node.js. But none of the solutions (all involving some form of setting max-old-space-size) work to clear this for me. As far as I can tell, all my Node and JS installs, as well as the CDK install are up to date.
I can repeatedly duplicate this by creating a new project, then trying to run synth or deploy on it:
cdk init app --language csharp
cdk synth
I've been struggling with this for several days and have no more ideas. Any suggestions would be welcome.
I am creating a winform apps in vs2019, create report via Report viewer and it's work well. However, when i embed the dll using Fody/Costura, somehow the report viewer give an error.
I also try manually embed the dll, but the same error still occur.
The error message appear in report viewer,
An error occured during local report processing.
The definition of the report " is invalid.
An unexpected error occured in Report Processing.
The type initializer for "Microsoft.Reporting.Services.ReportIntermediateFormat.Persistence.IntermediateFormatVersion" threw an exception.
The path is not a legal form.
Any help would be very appreciated. Thanks.
I encounter the same problem today. Base on the inner exception, it seems report viewer need to get the version of it's related dll to work correctly. If the dll is embeded, report viewer couldn't locate it.
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String fileName)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.IntermediateFormatVersion.<>c__DisplayClass2_0.<.cctor>b__0()
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1_0.<Run>b__0(Object state)
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback)
at Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.IntermediateFormatVersion..cctor()
--- End of inner exception stack trace ---
After some trial and error, I found that for report viewer working correctly, 'Microsoft.ReportViewer.ProcessingObjectModel' and 'Microsoft.ReportViewer.Common' need to be exclude from Fody/Costura. Following is the FodyWeavers.xml I'm using.
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura>
<ExcludeAssemblies>
Microsoft.ReportViewer.ProcessingObjectModel
Microsoft.ReportViewer.Common
</ExcludeAssemblies>
</Costura>
</Weavers>
I recently had problems opening my Designer View of a form hat acts as launcher for all the other forms.
The solutions I found according to that suggest to delete the .RESX files which helped for some days now (always had to delete RESX before debuging the program) today, after trying to debug another time I got stuck with this screen:
This seems to be caused by me deleting the resx files.
I can not find anything according to this online.
I tried to rebuild the project, getting the deleted file(s) back from the paperbin but nothing seems to help right here and I just do not understand what this error message is supposed to tell me...
bei System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
bei Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
bei Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetFileDocData(String fileName, FileAccess access, String createTemplate, Boolean addToHostList, Boolean nestedItem)
bei Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomProvider.OnParseBegin(TextReader reader)
bei Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.Parse(TextReader codeStream)
bei Microsoft.VisualStudio.Design.Serialization.CodeDom.MergedCodeDomParser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
bei System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
bei Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
bei Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
bei System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
(Nothing in Errorlist)
I have a jpg in a folder in my project. I want to make a bitmap out of it but it says my path is invalid when I try to refer to the jpg.
https://i.stack.imgur.com/dAWIG.jpg
Console Exception:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Drawing.IntSecurity.UnsafeGetFullPath(String fileName)
at System.Drawing.IntSecurity.DemandReadFileIO(String fileName)
at System.Drawing.Bitmap..ctor(String filename)
at ConsoleImageCompare.Compare.differance(String img1, String img2) in c:\users\user\documents\visual studio 2017\Projects\ConsoleImageCompare\ConsoleImageCompare\Compare.cs:line 22
at ConsoleImageCompare.Program.Main(String[] args)
The reason is by default console application points to the bin/debug folder.So you need to go up two level to get the file
#"../../image/<Your File name>"
Use this
Hi I'm running the following code:
void bar()
{
var dirInfo = new DirectoryInfo("C:\foo\folder");
dirInfo.Delete();
}
And at one point I got the following exception:
System.IO.IOException: The process cannot access the file 'C:\foo\folder' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
at bar()
Two things bother me here:
I called DirectoryInfo's Delete(). Why did I get Directory's Delete() in the stack trace without DirectoryInfo's one?
How come the file that is being used has the same path as my folder? Is this an error in the message? Or was there a different error?
To answer the first of your questions, DirectoryInfo.Delete calls Directory.Delete. If you're running in release mode, it's possible the compiler has optimised your code and you're just seeing the underlying call.
Edit: I've just done some tests in VS2013. When my project was a release build compiled for Any CPU I could see the call to DirectoryInfo.Delete before the call to Directory.Delete in the stack trace:
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at System.IO.DirectoryInfo.Delete()
at test.Program.Main(String[] args) in c:\Projects\test\Program.cs:line 21
but when I compiled a release build for x64 it showed only the call to Directory.Delete:
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
at test.Program.Main(String[] args) in c:\Projects\test\Program.cs:line 22
It does look like some optimisation is going on (incidentally, the code was unchanged between tests - I'm guessing the change in line number is also related somehow to compiler optimisation).
Have a look at this question - directoryinfo delete vs directory delete
To answer your other question - did you have a file in the directory open in another app? There are many reasons why another process may be doing something to that folder.