'No Source Available' Error - c#

I copied my project to a dsik on key and tried to run it in my mother home pc.
In my code im using HtmlAgilityPack.HtmlWeb and i have this line:
private List<string> test(string url, int levels,DoWorkEventArgs eve)
{
levels = 0;
HtmlWeb hw = new HtmlWeb();
If i run my program it will not throw any exception but will continue just will not do anything.
If i put a breakpoint on the line: HtmlWEb hw = new HtmlWeb();
Im moving to a No Source Available window:
Locating source for 'D:\Source\htmlagilitypack.new\Trunk\HtmlAgilityPack\HtmlWeb.cs'. Checksum: MD5 {58 c1 63 f6 cd 5 65 de 4c 3c d5 4b b1 b7 7 48}
The file 'D:\Source\htmlagilitypack.new\Trunk\HtmlAgilityPack\HtmlWeb.cs' does not exist.
Looking in script documents for 'D:\Source\htmlagilitypack.new\Trunk\HtmlAgilityPack\HtmlWeb.cs'...
Looking in the projects for 'D:\Source\htmlagilitypack.new\Trunk\HtmlAgilityPack\HtmlWeb.cs'.
The file was not found in a project.
I see that HtmlWeb.cs is missing in some directory on D:\
I have also a try and catch in my function test if i put a breakpoint on the catch i see:
IOexception was caught.
The device is not ready.
My guess that its looking for a file maybe HtmlWeb.cs in D:\
And in my mother pc D:\ is a DVD drive in my pc its hard disk.
The full exception:
System.IO.IOException was caught
Message=The device is not ready.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
at GatherLinks.Form1.removeDuplicates(List`1 a, List`1 b) in F:\GatherLinks\GatherLinks\Form1.cs:line 250
at GatherLinks.Form1.test(String url, Int32 levels, DoWorkEventArgs eve) in F:\GatherLinks\GatherLinks\Form1.cs:line 111
InnerException:
I dont see any problems in my code in the reference area with the HtmlAgilityPack.dllim
Its not missing.
So i wonder why its looking for a file on D:\ ?
If on my pc i did rebuild/build solution and saved it all i was sure its adding all the files and dll's it needs to the project so if i copy it to my disk on key and run it on my mother pc it will work.
So what did i do wrong here ? And how should i fix/repair it ?

I erased the HtmlAgilityPack.pdb and it worked just fine. Erase the file, rebuild, close and reopen and see if it works

Related

Dot Net new console creation on VS Code

Whenever I go to vscode's terminal and type
dotnet new console
it gives me an error
Error while processing file /content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj
System.UnauthorizedAccessException: Access to the path '/Users/zohaibarsalan/Documents/programming/c#/learningc#/learningc#.csproj' is denied.
---> System.IO.IOException: Operation not permitted
--- End of inner exception stack trace ---
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path)
at Microsoft.TemplateEngine.Utils.PhysicalFileSystem.CreateFile(String path)
at Microsoft.TemplateEngine.Core.Util.Orchestrator.ProcessFile(IFile sourceFile, String sourceRel, String targetDir, IGlobalRunSpec spec, IProcessor fallback, IEnumerable`1 fileGlobProcessors, IReadOnlyList`1 locOperations)
how can I fix this?
I have installed dot net from Microsoft, so do I need to delete it, and if so how?
or do I have to change some settings?
This also happens on the terminal.
BTW this is on a MAC

Access Denied Error when using ZipFile Class

Background
I currently have a usb device which has all my projects which I am working on and it stays in my office's docking station. Last night I was bored and wanted to continue work on a project, However no files? This made me think about writing a console app that would copy all the files from my usb drive to a folder on my desktop and would run as a scheduled task at a certain hour.
Problem
I am trying to use a System.IO.Compression.FileSystem in order to compress the file in order in order to then move it to a new directory on my PC. The documentation gives an example here ZipFile class. IT seems very up front. However, when I am trying to copy it to a new destination I get the following error.
Error
Message
Access to the path 'C:\Users\er4505\Desktop' is denied.
StackTrace
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.DoCreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName, Nullable`1 compressionLevel, Boolean includeBaseDirectory, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.CreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName)
at ConsoleApp1.Program.Main(String[] args) in C:\FTG\Projects\CaseWare\ConsoleApp1\Program.cs:line 25
Code
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string[] folders = System.IO.Directory.GetDirectories(#"D:\", "*", System.IO.SearchOption.TopDirectoryOnly);
foreach (string folder in folders)
{
ZipFile.CreateFromDirectory(folder, path); << errors out here!
}
The 2nd parameter string destinationArchiveFileName should be a filename.
for Example "C:\Users\er4505\Desktop\example.zip"

WebClient.DownloadFile doesn't work

I am trying to download a file from my server, and I do this:
var client = new WebClient();
client.DownloadFile(#"C:\Files\project\result.xlsx", "download.xlsx");
and the exception says this:
2015-01-27 13:08:13,686 [55] ERROR GeneralLogger - System.Net.WebException: An exception occurred during a WebClient request. ---> System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\IIS Express\download.xlsx' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at EmailTemplates.Classes.ExcelUtil.CreateNewExcelFile(String variables) in
I never used the path C:\Program Files (x86)\IIS Express\download.xlsx probably is the default or something like that.
I want to dowlonad the file as when you click in download, on any page (i do this because i create the file in the same function)
Thanks.
I think you misunderstood what DownloadFile does. It does not send a file to clients of your web app. It downloads a file from a server. Since you did not specify any URL I assume that's your mistake.
Research how to send a file as the response to an HTTP request. I'd search for "ASP.NET download file".

Windows service cannot read file but application can

I have a Windows Service that needs to read a text file every 90 seconds or so and then do some actions. The problem is that I get 'Access Denied' errors when reading the file from a service, but I can read the file just fine from an app (using the exact same code). This is my first service so maybe I am missing something obvious? Here is the relevant code for the service (Doesn`t work)
protected override void OnStart(string[] args)
{
this.eventLog1.WriteEntry("my app in OnStart.");
ThreadPool.QueueUserWorkItem(new WaitCallback(ServiceWorkerThread));
}
private void ServiceWorkerThread(object state)
{
while (!this.stopping)
{
update_DB();
Thread.Sleep(90000);
}
this.stoppedEvent.Set();
}
protected void update_DB()
{
try
{
var lines = File.ReadAllLines("C:\\Users\\jkoegler\\Desktop\\text.xml");
//do a bunch of other stuff
}
catch (Exception e)
{
this.eventLog1.WriteEntry(e.ToString());
}
}
And here is what gets logged:
System.UnauthorizedAccessException: Access to the path
'C:\Users\jkoegler\Desktop\text.xml' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32
rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,
SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare
share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare
share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean
detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding)
at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
Now what gets me is that I can have this EXACT same code block (update_DB()) in a button click event in a regular windows forms app and it works fine. I can run the app at basically the same time as the service and it works just fine. What gives? I gave all users full access to the file and the folder. Thanks in advance
Windows services run as a specified user. You can view or change which user it is running under using the Services control panel.
Run: services.msc
or
Access via the Control Panel->Administrative Tools->Services
By default, it is probably running under the Local Service account, and that account probably doesn't have permissions to the file you are trying to read, but your account does.

How to convert *.jar that contains native call to a DLL(Mono C#)

We're using IKVM to convert our *.jar to dll that we using to migrate our code to C# with Mono..
We have a problem especially when working with jar contains a JNI call, expl JnativeHook, its make an error when we try to convert it using IKVM, i have reported the error to the author as the follow:
I'm trying to use JnativeHook.jar library, its work for my java apllications, However:
Not: JnativeHook its a cross-platform containes 3 .dll depends on the OS when the java application is running (dynamic loading of *.dll)...
JnativeHook.jar containes also a package(demo) that containes a main classe, i have solved this problem by deleting this one, now i'm sure that will be converted to dll...
finally, when i try to convert this one to .dll i get this error:
C:\Users\marwen\Desktop\Kid protector\Tools and IDE\ikvmbin-7.2.4630.5\bin>ikvmc JNativeHook.jar
IKVM.NET Compiler version 7.2.4630.5
Copyright (C) 2002-2012 Jeroen Frijters
http://www.ikvm.net/
note IKVMC0002: Output file is "JNativeHook.dll"
*** INTERNAL COMPILER ERROR ***
PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE
System.UnauthorizedAccessException: L'accès au chemin d'accès 'C:\Users\marwen\Desktop\Kid protector\Tools and IDE\ikvmbin-7.2.4630.5\bin\JNativeHook.dll' est refusé.
à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, Str
ing msgPath, Boolean bFromProxy)
à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
à System.IO.FileStream..ctor(String path, FileMode mode)
à IKVM.Reflection.Writer.ModuleWriter.WriteModule(StrongNameKeyPair keyPair, Byte[] publicKey, ModuleBuilder moduleBuilder, PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, Ima
geFileMachine imageFileMachine, ResourceSection resources, Int32 entryPointToken, Stream stream)
à IKVM.Reflection.Emit.AssemblyBuilder.SaveImpl(String assemblyFileName, Stream streamOrNull, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
à IKVM.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
à IKVM.Internal.CompilerClassLoader.Save()
à IKVM.Internal.CompilerClassLoader.Compile(String runtimeAssembly, List`1 optionsList)
à IkvmcCompiler.Compile(String[] args)
à IkvmcCompiler.Main(String[] args)
The response from the author:
>Comment By: Jeroen Frijters (jfrijters)
Date: 2013-02-12 03:28
Message:
Thanks. Fixed in cvs. BTW, the error is because ikvmc can't write to
JNativeHook.dll (probably because you don't have write access to the
directory).
As you can see the author has respond with a few words without giving us a solution..
What i understand is the embedded Dll make the error, in fact IKVM does not know how to work with it(inside the JAR)...
there is some suggestions to solve this problem?
PS: what does mean Fixed in cvs ?
Thank you.
The cause of the problem is that you have no write rights to the output location. Run the command on another location with write rights.
I think the fix will only prevent the "INTERNAL COMPILER ERROR" message.

Categories

Resources