|
You can't do it in managed code. That's a little technique call "DLL injection", which cannot be done in managed code because .NET does not support the exports required to pull it off.
You can still do what you want, just not in C#. It has to be done in C/C++.
|
|
|
|
|
Oh well now im sad.
btw, @dave is target app able to tell if dll is injected to them ? I mean obviously they do but is it like "hey my variable just froze, there must be an injected dll" or they somehow instantly realize ? (talking about big cheat protection systems like vac)
My hopes alredy in toilet now so im just wondering...
|
|
|
|
|
No, there is no way for the target application to know that it's had some DLL injected into it.
|
|
|
|
|
hi,
I have a C# app that access MSSQL 2000 via web service calls to retrieve/update some records. This app has been working well in Windows XP. The web services are also developed in C#. The MSSQL database is residing in a separate server.
Recently, I copy and run this app in a Windows 7 laptop. The time to retrieve/update some records has grown exponentially! It took almost 20 minutes to insert 1000 records, and almost 1 hour to insert 3000 records. These same functions could be carried out in less than 10 seconds in Windows XP.
I tried disabling IPV6, autotuning in the Windows 7 laptop, but that did not help. Any idea what could be the cause of such slowness and any suggestion to solve this strange behaviour is much appreciated.
Thanks!
|
|
|
|
|
There's really is not enough information to answer this question at all. Anything anyone says is purely guess work.
But, first things first. Was the laptop connected to the network over wireless or wired?? Do it on wired network and see what happens. Wireless can be excruciatingly slow compared to wired.
|
|
|
|
|
hi Dave,
Thanks for the response.
I have tried both wired and wireless network, and the results are the same. Please note the MS SQL2000 server, the web services and the C# application are running within an intranet.
I could not understand why a C# app running on a higher end Windows 7 OS laptop (higher processor, ram etc) could lose out to an old Windows XP OS laptop, in terms of accessing the database records.
Please note that the testing environment for both laptops are the same: MS SQL 2000 Server and web service running on Windows 2000 server. I am just running a C# application on both laptops that access the database via the web services.
Do I need to add additional libraries or something for the Windows 7 OS? I am really at a loss where / which direction should I be looking to troubleshoot the problem.
|
|
|
|
|
There are no additional libraries. Chances are really good it's something O/S related, not your code. The onyl thing I can think of is make sure the machine is patched up to latest, including IE patches.
|
|
|
|
|
Hello everyone
This is a program for downloading a file from a url
when i download a file i got a error like access to the path is denined can any one tell me why this happen
This is my code.
<pre lang="c#">
public static void Download(String strURLFileandPath, String strFileSaveFileandPath)
{
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(strURLFileandPath);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
Stream str = ws.GetResponseStream();
byte[] inBuf = new byte[100000];
int bytesToRead = (int)inBuf.Length;
int bytesRead = 0;
while (bytesToRead > 0)
{
int n = str.Read(inBuf, bytesRead, bytesToRead);
if (n == 0)
break;
bytesRead += n;
bytesToRead -= n;
}
try
{
FileStream fstr = new FileStream(strFileSaveFileandPath, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(inBuf, 0, bytesRead);
str.Close();
fstr.Close();
}
catch (Exception e) {
MessageBox.Show(e.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (phpurl.Text == "") {
MessageBox.Show("Invalid Url");
}
else if (Uri.IsWellFormedUriString(phpurl.Text, UriKind.Absolute) == false)
{
MessageBox.Show("Invalid Url");
}
else {
Download(phpurl.Text, @"D:\test");
}
}
Also this is my manifest file
="1.0"="utf-8"
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</application>
</compatibility>
</asmv1:assembly>
Please help me..
Thanks in advance.
|
|
|
|
|
The local user does not have the right to write to that particular location on the D drive.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
What line does this exception occur on??
Either the URL you've specified doesn't exist or you don't have permissions to see it or the filepath that you're writing to doesn't exist or you don't have permissions to write to it.
I think the meaning of the error is pretty obvious, given your code.
|
|
|
|
|
Dave Kreskowiak Thanks for your replay
this is the line exception occur.
FileStream fstr = new FileStream(strFileSaveFileandPath, FileMode.OpenOrCreate, FileAccess.Write);
Please help me.
Thanks in advance
|
|
|
|
|
Also make sure that file doesn't already exist on your system and is not open by another program (or even your own).
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Hi dybs,
That is a empty folder and there is no way to use the file by any other program.
Please help me.
Best regards,
Thanks in advance
|
|
|
|
|
The user that is running your code does not have permissions to write to either D:\ or to D:\test. Or, the filepath you specified in that line of code (use the debugger to find out what it is) doesn't exist.
|
|
|
|
|
Hi thanks for the replay
I found what is happening here
Download(textBox1.Text, @"D:\test\test.zip");
i have to tell destination file name and its extention!!!.
now my problem is when i download larger files (50 mb ) from my server it is not downloading the file.
i thing the problem is here.
byte[] inBuf = new byte[100000];
I thing the array is small so how can i manage it?
Please help me to do this...
Thanks in advance...
|
|
|
|
|
|
Have some patience. You posted this when the regular who answer questions (on their own time!) were either going to bed or were already there.
|
|
|
|
|
What you should do to avoid your buffer overflowing is to read some data to your buffer and then writing to the file, all within a loop. This is a very common technique, for example, to copy files.
|
|
|
|
|
Thanks for your replay.
can you explain your answer for better understanding?
Thanks in advance.
|
|
|
|
|
You can try something like this. I have modified your code slightly to place reading and writing inside the main loop. Also, I recommend having your streams inside a using block, it is simpler to write and safer if any exception is thrown.
Note: This code is untested!!
public static void Download(String strURLFileandPath, String strFileSaveFileandPath)
{
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(strURLFileandPath);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
byte[] inBuf = new byte[100000];
int bytesToRead = (int)inBuf.Length;
int bytesRead;
using (Stream str = ws.GetResponseStream())
{
using (FileStream fstr = new FileStream(strFileSaveFileandPath, FileMode.OpenOrCreate, FileAccess.Write))
{
try
{
while ((bytesRead = str.Read(inBuf, 0, bytesToRead)) > 0)
{
fstr.Write(inBuf, 0, bytesRead);
}
}
catch (Exception e) {
MessageBox.Show(e.Message);
}
}
}
}
|
|
|
|
|
Hi All,
I have come across a problem if I run an Executable built in VS 2008 to check the validity of some drivers for a purpose the first version I wrote errors after it has run and is about to exit, a second version the quicker version, wont run at all!
FileVersionInfo fsi = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\drivers\ftdibus.sys");
String AppPath = Directory.GetCurrentDirectory();
is the code encounter when it loads the form, Could this blow it out of the water as the try...catch I added is not operating at all, also the previous version ueses
ServiceController[] scDevices = ServiceController.GetDevices(); and then loads a list with the driver details and crashes after. As these programs both work on my dev PC, at least two other (XP & 7) but wont work on the older machines (2) (both XP) I'm starting to worry about Works on my PC syndrome! (could it be an issue with Service packs?)
Glenn
|
|
|
|
|
glennPattonWork wrote: Could this blow it out of the water as the try...catch I added is not operating at all,
In that case, the EventLog would be the first place to look for clues.
glennPattonWork wrote: and then loads a list with the driver details and crashes after.
Under what user are you executing the app? Is UAC enabled?
You can put the SharpDevelop-IDE on a USB-stick, and use that to debug the app on the machines where Visual Studio isn't installed. If the exception-handler is bypassed, you could try simple logging to get an indication where the application exits.
Not much help I'm afraid, but at least a starting-point.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
The EventLog mmm, give that a go.
As for users I assume admin rights but I just go check.
Hey-Ho I'm Back it appears to .NET2.0RunTime throwing an error 5000 on both machines which according to MSDN "This problem occurs because the default policy for unhandled exceptions has changed in the .NET Framework 2.0. By default, the policy for unhandled exceptions is to end the process." Prior to .Net2.0 it ignores." which is helpful
There does seem to be a bit on the .Net2.0 frame work not being installed properly, seems like a good time to do an update on both PC's one takes about 25 mins to boot and the other is a test laptop that dies if look at it wrong!
Glenn
modified 26-Jul-12 10:49am.
|
|
|
|
|
glennPattonWork wrote: Hey-Ho I'm Back it appears to .NET2.0RunTime throwing an error 5000 on both machines which according to MSDN "This problem occurs because the default policy for unhandled exceptions has changed in the .NET Framework 2.0. By default, the policy for unhandled exceptions is to end the process." Prior to .Net2.0 it ignores." which is helpful
Means that since .NET 2.0 the application dies if you have an unhandled exception.
glennPattonWork wrote: There does seem to be a bit on the .Net2.0 frame work not being installed properly, seems like a good time to do an update on both PC's one takes about 25 mins to boot and the other is a test laptop that dies if look at it wrong!
Did the repair help?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Oh boy I can see a day if Try Catch hell in front of me, the first attempt at re-installing all the available frame works didn't work, trying again after a night rest.
Well I have the laptop on my desk from the lab, it now looks as if the issue is caused by machines that don't have a component installed as I tried it another Windows 7 laptop and it died.
Glenn
-=-=-=-=-=-=-=-=-=-=-=-=-=-
EDIT
=-=-=-=-=-=-=-=-=-=-=-=-=-=
FileVersionInfo fsi = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\drivers\ftdibus.sys");
This was the line that was causing the program to crash! moved it to inside a button click all is well (now just to find a good try catch!)
Glenn
modified 27-Jul-12 7:52am.
|
|
|
|