|
Hello everyone,
I am using VS 2008 and writing a console project. I add a new web reference to a web services and it is successful. I have found Web Reference folder is generated and there is a file called Reference.cs containing proxy class.
My question is, how to use the proxy class in Reference.cs? Add this cs file manually to my project? If yes, add to which folder of the project?
thanks in advance,
George
|
|
|
|
|
The web reference folder is already within your project, right?
Just create an instance of the class in your code, and use that object to call the web service.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa!
1.
I have got your idea. But we still need to add using XXX in order to support to use the proxy class in related cs files, correct?
2.
It does not matter if the proxy class cs file does not appear in IDE?
regards,
George
|
|
|
|
|
1 - Your question is not clear. When you add reference to a WS, VS editor automatically generates proxy classes for it. You use these classes to do communication.
2 -
|
|
|
|
|
Thanks N a v a n e e t h!
Let me clarify.
1.
I mean we need to add "using <proxy class="" name="">" in other cs file, where we need to use the proxy class, correct? (my question is, IDE does not add reference automatically in the project, so we need to add using statement manually in each cs file where we need to use the proxy class);
2.
In "Solution Explorer" of Visual Studio, the generaed file Reference.cs does not exist. But it does not block us to use it in current project by add using statement in related cs files use the proxy class, correct?
regards,
George
|
|
|
|
|
George_George wrote: so we need to add using statement manually in each cs file where we need to use the proxy class)
YES.
2 - That file exists in the project folder. VS editor just hides it to prevent users editing it manually. Just click on "Goto definition" on any WS types, you can see the proxy class opens.
|
|
|
|
|
Cool, N a v a n e e t h!
Question answered.
regards,
George
|
|
|
|
|
If I understand your question correct you're trying to use the using clause to automatically dispose the instance of the class on the web reference you're creating right? You dont need to worry about the proxy class, just use the web reference exactly like you would use any normal dll reference.
|
|
|
|
|
Sorry, my English is bad. I mean I want to use "using" statement which is at the beginning of each cs file to import the namespace of the proxy class.
regards,
George
|
|
|
|
|
You will need to know the namespace that the classes you want to reference lays in. You use that namespace with the using clause at the top of your class:
eg.
namespace SampleNamespace
{
public class SampleClass
{
public static object oValue;
}
}
This you can use as:
using Samplenamespace;
public class Foo
{
public void Boo()
{
object sampleValue = SampleClass.oValue;
}
}
Hope this answers your question.
|
|
|
|
|
Thanks bcozican,
My question answered.
regards,
George
|
|
|
|
|
Hi all,
I would like to know when making use of the 'using' keyword and an exception occurred, will the exception be catered for in the 'using' scope?
Thus, if one would look at the following example(s), and lets say an exception occurred within the 'using' block below, will the exception be catched?:
Font font1 = new Font("Arial", 10.0f);
try
{
byte charset = font1.GdiCharSet;
}
finally
{
if (font1 != null)
((IDisposable)font1).Dispose();
}
using (Font font3 = new Font("Arial", 10.0f), font4 = new Font("Arial", 10.0f))
{
}
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Thanks...
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
You are welcome
|
|
|
|
|
It will be caught, eventually, but not by your try/catch block as shown. If you want your 'using' exceptions caught then the using needs to be in a try/catch block.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: If you want your 'using' exceptions caught then the using needs to be in a try/catch block.
Thanks that was helpful...
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
The using block generates a try...finally block. That ensures that the object is disposed even if an exception occurs, but it doesn't catch any exceptions.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for your response, it was very helpful.
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi All
I want to send a Keystroke to the window of other application.
I have got the Handle of that window.
Is there any API or Managed C# code which will directly send the Keystroke only to that window.
setting the window to foreground and then sending the keystroke is working fine.But in the meantime if the user click on other window that window becomes active and the keystrokes are send to that window not to that window for which it was meant.
I have also studied about SendMessage Api
SendMessage Function
Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
Syntax
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
But i do not know how to put Keystrokes input into msg variable
Does anybody know how to send only to particular window?
Thanks in advance
THE SK
(Sandeep Kalra)
I am the One
|
|
|
|
|
hWnd is the handle of the window that you want to receive the message. This is explained in the MSDN sendmessage [^] docs.
The message you want to send is probably WM_KEYDOWN and then WM_KEYUP. (You can find a full list of the messages and their numbers here[^])
Look here[^] for an explanation of the WM_KEYDOWN message, and what to put in the wParam and lParam parameters. You can use google to find a similar doc page for the WM_KEYUP message.
Simon
|
|
|
|
|
i have developed an app that have 1 array of int type with 3 elements, assign their values on Load event. Assign a timer that keep write their values in a textbox. Next, i run that app and got the first element offset in kernel32.dll by using a software. Now i want to write new values to that array from another application by using that offset i got. for example
int[] Xarray = new int[3];
private void Form1_Load(object sender, EventArgs e)
{
Xarray[0] = 61457899;
Xarray[1] = 44527899;
Xarray[2] = 832429;
}
i got address of first element(of Xarray) that is 0x1D52EF4 then the next element value i can find it on 0x1D52EF8 and third one on 0x1D52EFC
so if i write from another application like this
APIDecalaration.WriteProcessMemory(hProcess, (IntPtr)(0x1D52EF4), ref Newvalue, 4, 0);
APIDecalaration.WriteProcessMemory(hProcess, (IntPtr)(0x1D52EF8), ref Newvalue1, 4, 0);
APIDecalaration.WriteProcessMemory(hProcess, (IntPtr)(0x1D52EFC), ref Newvalue2, 4, 0);
[DllImport("kernel32")]
public static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, ref int lpBuffer, long nSize, long lpNumberOfBytesWritten);
then it will write Newvalue successfully, but i cant do because here are only 3 elements what if i have 100. Therefore, i made a struct that have 3 int variables but when i try to write it nothing happens. Here is code
APIDecalaration.WriteProcessMemory(hProcess, (IntPtr)(0x1D52EF4), Xstruct_instance, 12, 0);
[DllImport("kernel32")]
public static extern Xstruct WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, Xstruct lpBuffer, ref long nSize, long lpNumberOfBytesWritten);
[StructLayout(LayoutKind.Sequential)]
public struct Xstruct
{
public int Newvalue;
public int Newvalue1;
public int Newvalue2;
}
anyidea guys to solve this ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
A struct is a value type, so it will be allocated as a part of the application object instead of as a sepearate object on the heap, so it will have a completely different memory address.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
can you explain in little more detail ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
When you create an array it is created as a spearete object on the heap outside the Application object. When you create a struct as a member of the Application object, it will be allocated on the heap as part of the Application object. Naturally the address of those variables will be different.
Also, you can't rely on the address of anything that is allocated on the heap being the same every time you run the program. Subtle differences like user culture settings can easily change the number of objects allocated at startup.
Besides, the garbage collector can move any object on the heap at any time (unless the object is fixed).
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|