|
Assign a new CookieContainer to HttpWebRequest.CookieContainer and add a Cookie instance with the login data in the cookie returned by the web site. Do this before calling HttpWebRequest.GetResponse .
There are many ways of finding out the cookie's key/value pairs. One easy way is to use Mozilla Firefox and, after logging in, right click on the page and select Page Info. One of those tabs will show you current cookie values, IIRC.
Depending on how the site implements authentication, this cookie could be preserved for quite some time.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can somebody please tell me if it is possible to add some dlls to my setup project of my application (some graphic application), dlls like gdiplus.dll, so that the setup program will not check for the existence of the .net framework on the client machine - that is : it should run without it installed . the problem is that my application has 1.5 mb and including dotnetfx makes it over 25 mb.
thanks in advance, Bogdan
|
|
|
|
|
Sorry, can't do.
I believe you can compile your .Net application with the framework (necessary assemblies) embedded in it with Mono but I'm not sure.
Carl
|
|
|
|
|
Hi
Your concern is right. But to make the .NET independent of platform Microsoft has made it mandatory that if the client does not have the .NET platform but he wants to run .NET application then he has to have .net framework in it which you can download from Microsoft site.
So there is no other way to make your app run on client machine.
(This is same as having the Java JRE for Java app to run)
Hope you will get the point.
Naveen
|
|
|
|
|
ok, I understand it is not possible, but can I use the functions in gdiplus.dll and not use the whole .net framework? like include the gdiplus.dll in my source code and in my setup program for my application... is this the solution?
|
|
|
|
|
Yes sure, you can use the gdiplus.dll in your apllication.
No need of using whole of the .NET framework
Naveen
|
|
|
|
|
You're sure?
I'd rather doubt that Microsoft's license agreement allows you to rip apart the framework and distribute parts of it on your own...
mav
|
|
|
|
|
what im wondering is if there is a smaller version of the framework redistributable the one i found is 23698 KB
i mean thats just crazy for the ppl that are on a 56k hookup to have to DL that big of a file to run programs that were created in the .net framework
|
|
|
|
|
No, there is no such thing as a "micro .NET" doing everything the framework does but at 1/10th the size
There's no way around installing the framework on a client machine at least once. Newer windows versions already have .NET preinstalled, so in the future this will not be such a big point.
If you're only targetting people who have to download everything over a 56k modem then perhaps you should really opt for a different platform. Or make an ASP.NET application, so that you can use the advantages of .NET on the server side and your clients only need a browser.
mav
|
|
|
|
|
naw 56kers are not my main target i just tend to think of the ppl that dont have cable or dsl, I remember DLing a 24MB prog on 56k....it took forever
thanks for the info
|
|
|
|
|
Hi everybody,
I have a simple question but no answers to this...
On a C# client, I have 2 threads running: one for GUI and another one created for webservice synchronous calls.
When I click a button, I call 'SoapHttpClientProtocol.Abort()' on the GUI thread.
It then should abort a lengthy call (blocked) on a the worker thread and release the latter.
But it doesn't...
WHat's wrong!??!?
Thanks in advance!
|
|
|
|
|
Hi,
A client just sent me an obscure exception stacktrace that he got.
My guess is that it's a "one shot" exception (won't happen again) but still, I'd like to know what's going on. It doesn't even seem to have to do with my code.
How can I prevent such exceptions (I receive obscure exceptions like that once in a while)
Thanks!
Carl
Message: Object reference not set to an instance of an object.
Source: System.Windows.Forms/UnsafeNativeMethods.CallWindowProc
StackTrace: at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
OS Name: Microsoft Windows XP Professional|D:\WINDOWS|\Device\Harddisk0\Partition2
OS Version: Microsoft Windows NT 5.1.2600.0 System Type: X86-based PC Total Physical Memory: 535281664 Free Physical Memory: 262164 Windows Directory: D:\WINDOWS
|
|
|
|
|
Hi
i would like to explain a situation where this type of error might occur. In a windows form having a toolbar icon, place the cursor on any of the icons in the toolbar and try to do any other operation using the keyboard (may be by pressing the hot key combination). In these type of scenarios such error occurs... because when you have placed the cursor on the icon tooltip is being displayed and when u try to invoke any other procedure u get this error.
|
|
|
|
|
Any way to prevent this exception?
|
|
|
|
|
Hi Everybody
Im having a problem...
How can i install my assembly in my client machine which doesnt have the .NET framework.Actually i want to install my assembly in the client machine in the GAC so that the new version of the assembly can placed and used without any problem.
To install .NET framework in the client machine i have the dotnetfx.exe which will install the .NET framework in the client machine.
But how can i install my assembly in GAC there..
Any pointer ,any idea please let me know
Thanx a lot in advance
Naveen
|
|
|
|
|
Hi,
Open the Setup Project and then follow the below given steps:
Installing an Assembly to the Global Assembly Cache upon Installation
You can use the File System Editor to install an assembly to the Global Assembly Cache upon installation. To do so, the assembly must be incorporated in the setup project as a loose file and not compressed with the other project output. To install the assembly to the Global Assembly Cache, you must first sign your assembly with a strong name. Once your assembly has been strongly named, all you need to do is add a Global Assembly Cache folder to the File System Editor and add your assembly to that folder. Upon installation, your assembly will be added to the Global Assembly Cache.
To install an assembly to the Global Assembly Cache on installation
Sign your assembly with a strong name.
After creating your setup project, open the File System Editor.
Right-click the left pane and choose Add Special Folder. In the shortcut menu, choose the Global Assembly Cache Folder.
In the left pane, right-click the Global Assembly Cache Folder. Choose Add, and then choose Assembly from the shortcut menu. Choose the appropriate assembly or browse to its location and click OK to add the assembly.
The assembly will be added to the Global Assembly Cache upon installation. If the assembly was not already a part of your setup project, it is added to it.
Regards,
Sukesh.
Sukesh.g
|
|
|
|
|
I have a C# winforms app which starts other processes using System.Diagnostics.Process.Start. This all works except when the process has actually started the winforms app puts itself in front of the process which has just started. Is there a way to suppress this behaviour?
Thanks in advance...
We are the all singing, all dancing crap of the world. - Tyler Durden
|
|
|
|
|
I'm having trouble understanding your question. Specially this part:
<br />
This all works except when the process has actually started the winforms app puts itself in front of the process which has just started<br />
Could you clarify?
Thanks!
~javier lozano
(blog || email)
|
|
|
|
|
If the winforms app opens for example a Word document the sequence is as follows:
1) It opens the Word application.
2) The document is loaded in Word.
3) The winforms app main window put's itself in front of the Word main window.
In other words it seems that the winforms app does some sort of "SetForegroundWindow()" after the System.Diagnostics.Process.Start() returns.
Thanks,
Jan
We are the all singing, all dancing crap of the world. - Tyler Durden
|
|
|
|
|
A call to BringToFront() or Focus() after calling Process.Start should do the trick.
|
|
|
|
|
Further investigation has shown to me that the problem does not happen always. If I use Process.Start() to open a word or Excel document it does happen but if I open a text file it does not. When the problem occures the following happens:
1) Call Process.Start("somefile.doc");
2) The form receives a Form_Activated() event.
I should tell that the documents are opened via clicking in a treeview in which these files are listed.
I have found "sort of" a solution to the problem which pertains to calling SetForegroundWindow() on the MainWindowHandle of the created process when possible/necessary. Resulting in something like shown below. Sucks big time but it does the trick for now...
[DllImport("user32")]
private static extern IntPtr SetForegroundWindow( IntPtr hWnd );
[DllImport("user32")]
private static extern int GetAsyncKeyState( long vKey );
private void MainForm_Activated(object sender, System.EventArgs e)
{
try
{
if (( GetAsyncKeyState( 0x01 ) & ( 1 << 15 )) == ( 1 << 15 ) ||
( GetAsyncKeyState( 0x02 ) & ( 1 << 15 )) == ( 1 << 15 ) ||
( GetAsyncKeyState( 0x04 ) & ( 1 << 15 )) == ( 1 << 15 ))
{
prProc = null;
}
else if ( prProc != null )
{
if ( prProc.HasExited == false )
SetForegroundWindow( prProc.MainWindowHandle );
prProc = null;
}
}
catch ( InvalidOperationException )
{
}
}
Thanks...
We are the all singing, all dancing crap of the world. - Tyler Durden
|
|
|
|
|
Hi, i'm creating a C# DLL that i access from C++. The C# only connects to the database, creates three arrays, fills them, and passes the filled arrays (int[], double[], string[]) back to C++. The interop appears to be working fine, only my problem is in trying to convert a SAFEARRAY into an int[], double[] and string[] without compromising data integrity. This is my code to do this (at least for just the int[]):
C++:
SAFEARRAY * vi;
SAFEARRAYBOUND rgsaBound[1];
rgsaBound[0].lLbound = 0;
rgsaBound[0].cElements = 100;
vi = SafeArrayCreate(VT_INT, 1, rgsaBound);
spConnNET->Read();//this calls the method in C# to fill the arrays
//the code "spConnNET->ArrayInt()" retrieves the arrays from C#
HRESULT r = SafeArrayAccessData(vi, reinterpret_cast<void**>(spConnNET->ArrayInt()));
It is not changing it from a SAFEARRAY to an integer array though...can anyone tell me what i'm doing wrong, or what needs to be added?
thanks
|
|
|
|
|
just to update: i just changed my code to the following:
C++: (To convert safearray to int[])
//create SAFEARRAY to hold Integers:
SAFEARRAY * holdInt;
//safearray bounds:
SAFEARRAYBOUND bound[1];
bound[0].cElements = 100;
bound[0].lLbound = 0;
holdInt = SafeArrayCreate(VT_I4, 1, bound);
HRESULT r = SafeArrayCopyData(spConnNET->ArrayInt(), holdInt);
LONG pos[1];
LONG hold;
for(int h = 0; h < 100; h++)
{
pos[0] = h;
if (SafeArrayGetElement(holdInt, pos, (void *)&hold) == S_OK)
{
cout << hold << endl;
}
else
{
cout << "something's wrong" << endl;
}
}
Now, it prints out a series of "0's" and i know that's not what the result should be.
|
|
|
|
|
HI all,
I am facing a problem in accessing a VC++ 6.0 ATL COM object via a .Net application
The atl com dll is accessing another dll called OTAClient80.dll
The following piece of code has been written in ATL COM:
/* START OF CODE SNIPPET */
STDMETHODIMP TDDOORSApi::temp(int *count)
{
HRESULT hr = E_FAIL;
::CoInitialize(NULL);
ITDConnection *connect;
HRESULT hr = ::CoCreateInstance(__uuidof(TDConnection), NULL, CLSCTX_INPROC_SERVER, __uuidof(ITDConnection), (LPVOID *)&connect);
if (connect==NULL)
{
return hr;
}
connect->AddRef();
//OTAClient80.dll api
hr=connect->InitConnection("http://PC-P33774/TDBIN","","");//Making a connection to the an application server
if (FAILED(hr))
return hr ;
//OTAClient80.dll api
hr = connect->ConnectProject("TestDirector_Demo","admin",""); //Making a connection to a project on the server
if (FAILED(hr))
return hr;
IRunFactory *runPointer = NULL;
IList *runFieldList = NULL;
//OTAClient80.dll api
hr = connectionPtr->get_RunFactory ((IDispatch**)&runPointer);
//This line gives an exception..
//OTAClient80.dll api
hr = runPointer->get_Fields(&runFieldList);
//Release the connection and dsiconnect from the project
connect->DisconnectProject();
connect->Release();
::CoUninitialize();
return hr;
}
/* END OF CODE SNIPPET */
When I try to invoke this code from a C# windows application or a console application, the line
hr = runPointer->get_Fields(&runFieldList);
gives an exception as follows:
/* START OF EXCEPTION TEXT */
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception.
at DOORSTDLib.TDDOORSApiClass.temp(Int32& count)
at WindowsApplicationTesting.Form1.button1_Click(Object sender, EventArgs e) in c:\documents and settings\mahendsa\my documents\visual studio projects\windowsapplicationtesting\windowsapplicationtesting\form1.cs:line 123
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
WindowsApplicationTesting
Assembly Version: 1.0.1662.29448
Win32 Version: 1.0.1662.29448
CodeBase: file:///C:/Documents%20and%20Settings/mahendsa/My%20Documents/Visual%20Studio%20Projects/WindowsApplicationTesting/WindowsApplicationTesting/bin/Debug/WindowsApplicationTesting.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Interop.DOORSTDLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/mahendsa/My%20Documents/Visual%20Studio%20Projects/WindowsApplicationTesting/WindowsApplicationTesting/bin/Debug/Interop.DOORSTDLib.DLL
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
---------------------------------------------
/* END OF EXCEPTION TEXT */
Sometimes, I get the error as under:
/* START OF ERROR TEXT */
The value of ESP was not properly saved across function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared with a different calling convention.
/* END OF ERROR TEXT */
There are no errors if I invoke the dll from an MFC application.
The following is the code invoked from the C# application:
DOORSTDLib.TDDOORSApiClass obj = new TDDOORSApiClass();
obj.temp();
Can someone please throw some light as to where can the problem be / what is the solution?
Regards
Vipul
|
|
|
|
|
Hi,
with VC C# I tried to connect to several webservices through classes generated by wsdl.exe
when I start my app from VS, I always get the error:
- The request failed with HTTP status 503: Service Unavailable -
but when I start the exe (debug or release) from explorer everything works fine !
Any idee how to make debuging work ?
jobr1ch
|
|
|
|