|
RSACryptoProvider creation problem:
I used some code for RSACryptoProvider creation with smart card and CAPICOM COM object
The code worked well in Framework 1.1
but when I tried the same code in Framework 2.0
I got an following Cryptographic exception:
"Unable to open the access token of the current thread"
string url = string.Empty;<br />
rsa = null;<br />
certificate = null;<br />
RSACryptoServiceProvider.UseMachineKeyStore = true;<br />
<br />
CspParameters csp = new CspParameters();<br />
csp.Flags = CspProviderFlags.UseMachineKeyStore;<br />
ICertificate2 selectedCert = null;<br />
<br />
<br />
Store st = new Store();<br />
<br />
st.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, "My", <br />
<br />
CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);<br />
foreach (ICertificate2 currCert in st.Certificates)<br />
{<br />
<br />
if (currCert.HasPrivateKey())<br />
{<br />
selectedCert = currCert;<br />
break;<br />
}<br />
}<br />
if (selectedCert == null || selectedCert.HasPrivateKey() == false || <br />
<br />
selectedCert.PublicKey().Algorithm.FriendlyName != "RSA")<br />
{<br />
StringBuilder sb = new StringBuilder();<br />
sb.Append("Can't find a vaild certificate!\n\n");<br />
sb.Append("Valid Certificate Authorities are :\n");<br />
System.Collections.IEnumerator myEnum = issuerlist.GetEnumerator();<br />
while (myEnum.MoveNext()) sb.Append(myEnum.Current).Append("\n");<br />
throw new Exception(sb.ToString());<br />
}<br />
<br />
certificate = selectedCert;<br />
<br />
csp.KeyContainerName = selectedCert.PrivateKey.ContainerName;<br />
csp.ProviderName = selectedCert.PrivateKey.ProviderName;<br />
csp.ProviderType = Convert.ToInt32(selectedCert.PrivateKey.ProviderType);<br />
<br />
switch (selectedCert.PrivateKey.KeySpec)<br />
{<br />
case CAPICOM_KEY_SPEC.CAPICOM_KEY_SPEC_KEYEXCHANGE:<br />
csp.KeyNumber = 1;<br />
break;<br />
<br />
case CAPICOM_KEY_SPEC.CAPICOM_KEY_SPEC_SIGNATURE:<br />
csp.KeyNumber = 2;<br />
break;<br />
}:omg:<br />
if (selectedCert.PrivateKey.IsMachineKeyset())<br />
{<br />
csp.Flags = CspProviderFlags.UseMachineKeyStore;<br />
}<br />
try<br />
{<br />
rsa = new RSACryptoServiceProvider(csp);
}<br />
catch<br />
{ }
|
|
|
|
|
I am trying to run application on remote pc by doing some thing like this:
ConnectionOptions objConnectionOptions = new ConnectionOptions();
objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate;
objConnectionOptions.EnablePrivileges = true;
objConnectionOptions.Username = strUserName;
objConnectionOptions.Password = strPassword;
ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions);
objManagementScope.Connect();
ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null);
ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create");
inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe";
ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null);
But for some reason it does not work and I don't know why???????
outParamsFinal["processId"] returns null, instead of a valid processId.
Is there any one who could help me in that..............
Thanks
Sarfraz
|
|
|
|
|
after i made my website and aspx pages
and i upload the website
i recive this error
Server Error in '/' Application.
-----------------------------------------------------------------------------
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".
<configuration>
<system.web>
<customerrors mode="Off">
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.
<configuration>
<system.web>
<customerrors mode="RemoteOnly" defaultredirect="mycustompage.htm">
----------------------------------------------------------------------------
so can any one solve this problem
or tell me how to solve it
thanks all
bye
Ahmed EL Gendy
|
|
|
|
|
Change the web.config as suggested, or if you're able, get onto the box (ie using terminal services or similar) then when you run the application it'll give you the stack trace which should help you locate the error.
.NET hides the full details by default unless you're running it on the box where the web application is hosted.
|
|
|
|
|
Hi,
On internet, i see everyone said : "If you are not sure which port is available, you can use 0 and server will search automatically for available port", but i doubt how could client call method on server when client don't know server's port?
Example :
On Server
ChannelServices.RegisterChannel(new TcpServerChannel(0));
On Client
MyClass obj = (MyClass)Activator.GetObject(typeof(MyClass),"tcp://localhost:?/Hello");
What number could i put in "?" ?
|
|
|
|
|
i want to create button
when click that button it's return 1 ,0
the returned number in random way
ma_refay
|
|
|
|
|
Random class[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Buttons don't have return values.
(new Random()).NextDouble(); will give you a random number between 0 and 1, inclusive.
File Not Found
|
|
|
|
|
i want the answer of that work tody to finish my tasks iam lating
i want to make an array that contain of 25 numbers this array contain only 0,1 and the aray is create random so the arrang of number is chane automaticaly evry time i create it
ma_refay
|
|
|
|
|
Random r = new Random();
int[] arr = new int[25];
for(int i = 0; i < 25; ++i)
arr[i] = r.Next() % 2;
|
|
|
|
|
Random class[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
What i need to do is to get the path on the local filesystem were a notepad application is saved. I have written a C# console application which spawns a notepad process. When the user clicks on the notepad File -> Save menu I need to capture the location where the it is saved.
I used System.Diagnostics.Process to start the notepad process. it seems I have to use P/ Invoke to get the work done. But can't figure out how. Please help me.
Thanks.
Harsha Kamat
|
|
|
|
|
Try Environment.GetFolderPath(Environment.SpecialFolder.System) to get the system path, then
Path.Combine(..., "notepad.exe")<br />
<br /> Or alternatively Process.Start("notepad.exe") (which uses the shell).
|
|
|
|
|
The 'Environment.GetFolderPath(Environment.SpecialFolder.System)' will give the path to the notepad.exe application. What i want is the local filesystem path where the contents of a new Notepad will be saved. i.e the path the user selects in the FILE->SAVE menu of the Notepad application.
Harsha kamat
|
|
|
|
|
Don't think that's possible without some really clever low-level API hooking wizardry and several large pinches of salt.
|
|
|
|
|
How to access variable in one Form from anothre form, and how to send data or messeges
between them.
I have two forms (Forms1 and Fomr2) and what i want is: when i click on a specific button in Form1 i want a specefic message (migth be written in textbox in Form1) to be sent to Form2 and then displayed
in listbox there.
|
|
|
|
|
|
public static variables will do the trick.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
A client is getting the below exception when trying to open a control.
Exception: System.IO.FileNotFoundException: Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.<br />
'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I've looked around the internet and people suggest that you should have the latest .net framework installed, which she does. Im quite stuck, because this doesnt happen on any development PCs.
Any ideas?
Regards,
Gareth.
|
|
|
|
|
Hi,
vjslib.dll is part of J#, it contains things such as a zip class and a biginteger class.
So if you are using C# (through Visual C# Express) now is the time to also
download and install Visual J# Express.
|
|
|
|
|
Hi Luc,
The problem is that we dont want users to install programs since the control is based in a web client. Is there a way around this?, eg embeding the vsjlib somehow.
Regards,
Gareth.
|
|
|
|
|
Hi Gareth,
no:
- AFAIK you cant embed a dll into something else
- you are not allowed to distribute parts of .NET
but you may find a way around without vsjlib by using other classes that are available,
or by creating your own. What is it you really need ?
|
|
|
|
|
Hi Luc,
Im using a 3rd party DLL which creates some graphs, that uses the vsjlib. So i cant not use vsjlib since its not my code
I've contacted the 3rd party company but was hoping there might be just a simple way around it.
Regards,
Gareth.
|
|
|
|
|
I see.
You might consider another graphing approach then; there are several graphing articles
on CodeProject (and lots of commercial products as well of course).
|
|
|
|
|
To consider another approach would mean a months work would be wasted and a license fee payment wasted as well.
I found on the web you can distribute the vjslib.
http://www.codecomments.com/message160639.html
The problem now is, how do i make the 3rd party dll look at my version of vjslib and not the one in the windows directory.
Regards,
Gareth
|
|
|
|