|
thank you,
finally, i did this:
<br />
<br />
System.Xml.XmlNodeList nodeList = XmlDoc.GetElementsByTagName("X509Certificate");<br />
XmlNode node = (XMLNode)nodelist[0];<br />
CAPICOM.Certificate certificates = new CAPICOM.CertificateClass()<br />
certificate.Import(node.InnerText);<br />
<br />
..and it seems that works well
|
|
|
|
|
What are you confused about? The InnerText is the base64-encoded X.509 certificate, so Import should have no problem reading it (as long as such a method accepts base64-encoded text, which that one obviously does).
You should really try to avoid interop'ing the CryptoAPI, however. Most of the functionality you most likely need is already in the .NET Framework SDK. Mixing like this creates additional requirements, not to mentioning that marshaling data types from managed to unmanaged code can be very time consuming for certain types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok. i'll try to do it without CryptoAPI.
thank you.
|
|
|
|
|
Hello all,
I am writing a app in C# and would like some direction on threads. I have the UI classes that includes a another non UI class and the ui class regesters events with the worker class. I want the worker class to take care of doing work in another thread. so the UI hooks up event calls something in the worker class and the worker class creates a new thread does some work and then trigger the event, but it need to call the event back on the UI thread. Any ideas on how to do this? Or a better design? Ideally I would like a good article or example etc. to look at/read. Thanks
Luke
|
|
|
|
|
C# Worker Thread Starter Kit[^]
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
My C# project needs to open a picture from an existent filepath,
after some processes, write back with the same filename.
I used filestream to open and save my file,
<br />
using(FileStream open = new FileStream(path,FileMode.Open,FileAccess.ReadWrite,FileShare.ReadWrite))<br />
{<br />
using (Image img = Image.FromStream(open))<br />
myPicture.PictureBox.Image = (Image)img.Clone(); <br />
}<br />
...<br />
...<br />
using(FileStream saveStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite,FileShare.ReadWrite))<br />
{<br />
PictureBox.Image.Save(saveStream,System.Drawing.Imaging.ImageFormat.Bmp);<br />
}<br />
I can open my picture and show it successfully,
but when I want to save,
there's always "A generic error occurred in GDI+" message except the first time,
I find it seems to be the problem of permission,
but I don't know the solution.
Can anyone tell me how to solve it...??
Thanks a lot!!
|
|
|
|
|
Hello!
I have the following problem: I want to open a file that is permanently opened for write operations by another application. It is a log file.
I always encounter the same problem: the file is already opened and I couldn't find any method to open it anyway.
The purpose is to check the log from time to time without writing anything, just as easy as opening it with Notepad (which works just fine).
Is there a way to open it?
10x!
|
|
|
|
|
Open the file as readonly while permitting other applications to write to it - which is probably what Notepad is doing.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
You need to request shared read access like so:
FileStream file = new FileStream(path, FileMode.Open,
FileAccess.Read, FileShare.Read);
using (file)
{
} If you don't request shared read access or simply read access, then no sharing is assumed and read/write access will also be assumed (which isn't allowed since the logging application has denied shared write access).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi all,
does anyone know how to lock tables with ms sql?
thanks guys,
chris
|
|
|
|
|
|
Probably this post is better suited to the SQL/ADO forum...
Anyway, to lock a table exclusively for the duration of the command, include the directive (TABLOCKX) after the table name, for example SELECT * FROM Customers (TABLOCKX) .
my blog
|
|
|
|
|
Thanks guys and sorry for posting the question in the wrong forum.
Cheers,
Chris
|
|
|
|
|
Hi~
Does the Windows XP connection firewall influence the traffic of ActiveSync?
Thanks~
|
|
|
|
|
If ActiveSync uses a TCP connection (found in corporate domain setups sometimes), yes. Otherwise, ActiveSync communicates through the USB or COM port, which is not controlled by the firewall.
If ActiveSync establishes an output TCP connection on behalf of your PocketPC, this shouldn't be a problem, either. The XP/2003 firewall allows all out-bound communication (though that will change a little with XP SP2, but the .NET Framework will be updated to accomodate that). If a service ActiveSync/PocketPC uses requests a user-defined port (like Active FTP), then there could be a problem since that port would most likely be blocked.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have to search a public Exchange folder in a C# application.
The public folder is visible only for one user, so I tried to add Credentials to the web request,
as it is described in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_exch2k_searching_calendar_folders_webdav.asp ^:
<br />
MyCredentialCache = new System.Net.CredentialCache();<br />
MyCredentialCache.Add( new System.Uri("http://myFolderURI"),<br />
"NTLM",<br />
new System.Net.NetworkCredential(strUserName, strPassword, strDomain) );<br />
<br />
HttpWebRequest request = WebRequest.Create(myFolderURI);<br />
request.Credentials = MyCredentialCache;<br />
Exchange does not use the credentials. I may access the server, so the credentials are working. But Request.GetResponse() throws an exception "404 Not Found".
I checked the folder path in Outlook Web Access and found out that Exchange uses the login information I've entered only for the personal folders. For public folders my Windows authentication is used.
That means if Im logged on to Windows as user "A" and log on to Web Access as user "B", I see the personal folders of "B" and the public folders as if I were "A". The same applies to WebDAV. The credentials are only usedfor personal folders, but I cannot access the public folders that are visible to the user specified in the credentials.
So my application has to impersonate the user before accessing Exchange. This worked with CDO before, so I think it should work here, too.
<br />
myContext = myWindowsIdentity.Impersonate();<br />
WebRequest request = WebRequest.Create(strCalendarURI);<br />
Now WebRequest.Create throws an exception:
Exception in cofiguration handler (c:\windows\microsoft.net\framework\
v1.1.4322\Config\machine.config line 74)
machine.config contains a line proxy usesystemdefault="true" , telling WebRequest to read the LAN settings from the registry.
This must fail, because the CURRENT_USER hive of the impersonated user is not loaded.
To override this setting I created a configuration file "appname.exe.config" in the /bin/Debug folder, but it changed nothing. My configuration file is not being used - What's wrong?
How can I access the public folder as anotehr user via WebDAV?
...get impersonation and the config file to work?
...get Exchange to accept my request credentials instead of using Windows Authentication?
Thanks for every hint,
coco
|
|
|
|
|
Interesting problem. So when you redefine that in your app.config, it's not affecting anything? Since machine.config is the parent config section, any changes in your app.config will overwrite those changes (or add to/remove from/clear a collection, etc.).
The weird thing is that your Windows Identity is obtained through NTLM, for which your providing credentials. So when you use a web browser that supports NTLM (IE and Mozilla 1.7+) that identity is obtained through NTLM. The username is used to resolve the path, while the credentials are used to authenticate the user.
On thing you could try is to assign your own WebProxy to HttpWebRequest.Proxy . That should override any checking for registry settings. Also keep in mind that proxy discovery isn't in the registry and .NET won't parse that information. Would be nice if they added support for that in future versions of the Framework.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I want to debug my service, from Onstart() and in MSDN says we need to create another service (dummy) to call the main service, which I need to debug. How to call a service from another service??
Regards,
Satya
|
|
|
|
|
Actually, you can use any application and then use the ServiceController to reference and start your service. This allows you time to attach to a process (or start the process that starts your service) so that you can debug the service all the way from OnStart . If you don't do it this way, all you can do is attach to a running process (your service). By the time the process has started, OnStart has already been called. That's the reason for a separate process to start the service.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
This a doubt regarding a service written in C#. I have a service, (developed by some one else), and I modified the dll of the service. Now, the service starts and stops. Is it correct to do the modifications directly in the dll code. Mean to say, will it be any problem with registration kind of thing.
Please clarify my doubt.
Regards,
Satya
|
|
|
|
|
That greatly depends. If the checksum of the PE/COFF executable was no updated, the SCM (service control manager) or even the executable loader may find that the executable is invalid and won't load and execute it.
Make the modifications to the source if you have it, and reinstall the service. You could alternatively export the IL, change it, and reassemble it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to convert a SVG Path string to .NET System.Drawing.Drawing2D.GraphicsPath ?
Who can tell me where can I find the source?
|
|
|
|
|
I don't know of any source for this myself, although it wouldn't be all that hard to write. If you find code for this, I'd be interested. I've been wanting to do this in a utility I'm writing, but haven't had time to work on it recently.
"A people that values its privileges above its principles soon loses both." -- Dwight D. Eisenhower
|
|
|
|
|
i am catching WM_ messages from my form and monitoring for WM_POWERBROADCAST messages which are dispatched when windows goes to sleep (thanks for the suggestions, Heath). but the problem is windows doesn't seem to make any distinction between STANDBY and HIBERNATE. when i place my computer in either standby or hibernate mode, both WM_POWERBROADCASTs are identical (ie, WPARAM values are equal, LPARAM are both 0). the SystemEvent class in .NET also has no distinction (either resume or suspend modes). i even analyzed ALL windows messages sent around the time the WM_POWERBROADCASTS are sent and tried to see if there are any unique windows messages sent just prior to or after the WM_POWERBROADCASTs to see if i could distinguish based on what other messages are sent. no luck there either.
am i basically just out of luck if i want to know whether my system is going into either standby or hibernate?
thanks!
|
|
|
|
|
This might get slightly ugly, however what you may need to do is look at the DEVICE_CAPABILITIES[^] returned from a IRP_MN_QUERY_CAPABILITIES[^] request. Specifically you will want to look at the SystemWake of the DEVICE_CAPABILITIES . Native code or at least MC++ would make things much easier on your end.
- Nick Parker My Blog | My Articles
|
|
|
|