|
Heres the code I have thus far. I can get it to encrypt it seems but Im not sure if it is encrypting correctly, or decrypting correctly...
I use the Page_Load just to debug by loading a standard authors.xml file...
I keep getting a root element missing exception when trying to load the encrypted file.
I am using a static key and IV and I know I should use ASCIIEncoding instead of UnicodeEncoding for that but will change it later once I can get it working....
[code]
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace ReadingXML
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button btnReadXML;
private System.Windows.Forms.Button btnShowSchema;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button btnUpdateXML;
DataSet dsAuthors = new DataSet("authors");
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.btnReadXML = new System.Windows.Forms.Button();
this.btnShowSchema = new System.Windows.Forms.Button();
this.btnUpdateXML = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 232);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(672, 104);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(680, 224);
this.dataGrid1.TabIndex = 1;
//
// btnReadXML
//
this.btnReadXML.Location = new System.Drawing.Point(40, 344);
this.btnReadXML.Name = "btnReadXML";
this.btnReadXML.TabIndex = 2;
this.btnReadXML.Text = "Read XML";
this.btnReadXML.Click += new System.EventHandler(this.btnReadXML_Click);
//
// btnShowSchema
//
this.btnShowSchema.Location = new System.Drawing.Point(136, 344);
this.btnShowSchema.Name = "btnShowSchema";
this.btnShowSchema.Size = new System.Drawing.Size(88, 23);
this.btnShowSchema.TabIndex = 3;
this.btnShowSchema.Text = "Show Schema";
this.btnShowSchema.Click += new System.EventHandler(this.btnShowSchema_Click);
//
// btnUpdateXML
//
this.btnUpdateXML.Location = new System.Drawing.Point(248, 344);
this.btnUpdateXML.Name = "btnUpdateXML";
this.btnUpdateXML.TabIndex = 4;
this.btnUpdateXML.Text = "Update XML";
this.btnUpdateXML.Click += new System.EventHandler(this.btnUpdateXML_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(688, 381);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnUpdateXML,
this.btnShowSchema,
this.btnReadXML,
this.dataGrid1,
this.textBox1});
this.Name = "Form1";
this.Text = "ReadingXMLExample";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
// string cryptFile="C:\\Documents and Settings\\Eric L. Golpe\\My Documents\\Visual Studio Projects\\ReadingXML\\bin\\authors.xml";
// DataSet dsAuthors = new DataSet();
// dsAuthors.ReadXml(cryptFile);
// dataGrid1.DataSource = dsAuthors;
// dataGrid1.DataMember = "authors";
// dataGrid1.CaptionText = dataGrid1.DataMember;
}
private void btnReadXML_Click(object sender, System.EventArgs e)
{
try
{
// The encrypted file to be read from.
string cryptFile="C:\\Documents and Settings\\Eric L. Golpe\\My Documents\\Visual Studio Projects\\ReadingXML\\bin\\authors.bsc";
// Create key and IV hash
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes("elg08754");
// Instantiate new crypto object
RijndaelManaged RMCrypto = new RijndaelManaged();
// Create an instance of StreamReader to read from a file.
FileStream cryptedstream = new FileStream(cryptFile, FileMode.Open, FileAccess.Read);
// Create New MemoryStream object to hold unencrypted data
MemoryStream memstream = new MemoryStream();
// Open a CryptoStream linking objects
CryptoStream cs = new CryptoStream(cryptedstream,
RMCrypto.CreateDecryptor(key, key),
CryptoStreamMode.Read);
int data;
while ((data=cs.ReadByte())!=-1)
memstream.WriteByte((byte) data);
// Create the DataSet to hold the data.
DataSet dsAuthors = new DataSet();
// populate the dataset with the XML String now in memstream
dsAuthors.ReadXml(memstream, XmlReadMode.ReadSchema);
// Set the datasource and display the data;
dataGrid1.DataSource = dsAuthors;
dataGrid1.DataMember = "authors";
dataGrid1.CaptionText = dataGrid1.DataMember;
// Close the streams
cs.Close();
memstream.Close();
// We're good, set the 'good to go' message
MessageBox.Show("Everything is OK", "OK");
}
catch (Exception x)
{
MessageBox.Show("Decryption failed!\nSpecific Details: " + x.ToString(), "Error");
}
}
private void btnShowSchema_Click(object sender, System.EventArgs e)
{
System.IO.StringWriter swXML = new System.IO.StringWriter();
dsAuthors.WriteXmlSchema(swXML);
textBox1.Text = swXML.ToString();
}
private void btnUpdateXML_Click(object sender, System.EventArgs e)
{
// The following function uses Rijndael encryption algorithm to encrypt file
// Because the Rijndael algoritm is private-key algoritm we need one
// private key and IV. I composed private key from password entered by user.
// IV is the same as password but this probably is not good.
// A key and IV have to be exactly 16 bytes length so we have to truncate
// password if it is longer then 8 characters (16 bytes) or to add some characters
// if password length is less then 8 characters.
try
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes("elg08754");
string cryptFile="C:\\Documents and Settings\\Eric L. Golpe\\My Documents\\Visual Studio Projects\\ReadingXML\\bin\\authors.bsc";
FileStream fsCrypt=new FileStream(cryptFile, FileMode.OpenOrCreate);
RijndaelManaged RMCrypto = new RijndaelManaged();
//Create a new temporary stream object
MemoryStream memIn=new MemoryStream();
// Write XML formatted data to the crypto stream with the schema from the dataset to the stream
dsAuthors.WriteXml(memIn, XmlWriteMode.IgnoreSchema);
//Creat the CrytoStream Object to do the encryption.
CryptoStream cs = new CryptoStream(fsCrypt,
RMCrypto.CreateEncryptor(key, key),
CryptoStreamMode.Write);
// Write the crypted data to the MemoryStream;
int data;
while ((data=memIn.ReadByte())!=-1)
cs.WriteByte((byte) data);
MessageBox.Show("Everything is OK", "OK");
// Close the crypto stream
memIn.Close();
cs.Close();
fsCrypt.Close();
}
catch (Exception xx)
{
MessageBox.Show("Encryption failed!\nSpecific Details: " + xx.ToString(), "Error");
}
}
}
}
[code]
Practice sesquipedalianism!
|
|
|
|
|
I don't see what the problem is. Have a method that reads a file, decrypts it, and reads that in to a DataSet (DataSet.ReadXml ). Of course, this requires that the application reading the file can access the private key of the key pair from which the public key was used to encrypt the file. Make sure this is secured well and that it isn't distributed to clients in a haphazard way. Once someone gets a hold of the private key, there's nothing they can't do!
Since you are working with XML, you might consider XML Encryption and Signatures. I have an article about XML Digitial Signatures and encryption isn't much different: http://www.codeproject.com/dotnet/xmldsiglic.asp[^]
Being a industry standard and all, it is a lot better to use for practically any system that understands XML. This also takes the canonicalization of XML into account, which can be important when submitting text files (for instance, changing the line-endings via encoding changes could invalidate the document and it won't be descrypted correctly).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Did not know where else to post this....I have tried just about everything to get this to work but can't figure out. I am getting "Unspecified error" when trying to open Visual Source Safe from Visual Studio 2003 .NET. I have completely uninstalled VSS and VS.NET the reinstalled, have all updates. I can access VSS and VS.NET by themselves but can't get to VSS from VS.NET when I go to File > Source Control > Microsoft Visual SourceSafe.
Anyone have any answers?
Thanks,
John
|
|
|
|
|
If you rename a subproject in a Visual Studio .NET Enterprise Template project before you check out the solution, Visual SourceSafe updates the solution but does not check out the solution.
Later, when another user tries to work with the source code control copy of the project, the user may receive "Unspecified Error" messages.
CAUSE
When you rename the subproject, Visual SourceSafe updates the source control information in memory to the solution file. However, because you did not check out the solution file, SourceSafe does not change the source control copy of the solution.
RESOLUTION
To work around this issue, follow these steps:
Close the solution, which may require you to quit the Visual Studio .NET integrated development environment (IDE).
Delete all of the .vsscc, the .vssscc, and the .vspscc files from all of the project and solution folders.
Reopen the solution.
Remove any projects that will not load, and then add them.
Projects may not load for several reasons, for example, because the binding information may be incorrect, or because you may receive errors.
Add the solution to source code control to a new project.
Practice sesquipedalianism!
|
|
|
|
|
I've been getting a weird flicker with my TabControl (.NET Windows Forms) when I try and use it
in a dynamically resizable window. I can move the window around and it paints fine but resizing it looks pretty bad. Any ideas?
Thx,
Sieg
|
|
|
|
|
SYMPTOMS
When making a call to TabPage.setSelectedTab() from within an OnSelectedIndexChanged event handler of the parent TabControl, the focus will first go to the user-selected index before returning to the index value set in the setSelectedTab() call. In addition, when returning to the index set in code by the setSelectedTab() call, the children components of the set TabPage will not be visible and Control.setVisible(true) must be used, causing a noticeable flicker.
RESOLUTION
To work around this problem, call Control.setVisible(true) on the TabPage after the setSelectedTab() call is made.
Maybe on the resize event you need to again setVisible(true) to get the flicker to go away? Give it a whirl and see what happens...
Practice sesquipedalianism!
|
|
|
|
|
I have error in my clients's computer when view report. The error is "Cannot find keycodev2.dll or invalid keycode" I already follow this article http://support.crystaldecisions.com/library/kbase/articles/c2011205.asp. But i still have this error. Please help mee Thanks
|
|
|
|
|
Hi all
Is it possible to run MC++ apps from (for example) a C# .NET web application ? I'll be checking with the host but was wondering if anyone else had done this or similiar.
BTW the app in question 'brands' .EXE files for registered customers and I'd prefer not to port the existing code to C# etc.
TIA
Jerry
|
|
|
|
|
Why do u wanna run it as an app? Just load it as an assembly reference!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Go on. Gimme a bit more detail )
|
|
|
|
|
One of the major benefits of Microsoft® .NET is that it provides a language-independent development system. You can write classes in Visual Basic®, C++, C#—whatever—and use them in other languages; you can even derive from classes in a different language. But what happens when you want to call some old-school unmanaged DLL? You have to somehow translate .NET objects into the structs, char*'s, and function pointers C expects. In techno lingo, your parameters must be marshaled. Marshaling is a big topic, but luckily you don't have to know much to get the job done.
To call a DLL function from C#, first you must provide a declaration, something programmers using Visual Basic have been doing for years. In C#, it's DllImport:
using System.Runtime.InteropServices; // DllImport
public class Win32 {
[DllImport("User32.Dll")]
public static extern void SetWindowText(int h, String s);
}
In C#, you use DllImport to tell the compiler where the entry point lives and bundle your wrapper functions inside a class. You can give this class any name you like; I chose Win32. You can even put the class inside a namespace. To compile Win32API.cs, type:
csc /t:library /out:Win32API.dll Win32API.cs
Now you have a Win32API.dll you can use in any C# project.
using Win32API;
int hwnd = // get it...
String s = "I'm so cute."
Win32.SetWindowText(hwnd, s);
Practice sesquipedalianism!
|
|
|
|
|
Indeed and Thanks. My question was obviously not well phrased. Given that I have a working VC++ console app I could compile it for IL instead of native code. Would this package then run on a remotely hosted .NET server along with my Web Service ? Would this be true for an unmanaged (but still compiled to IL) DLL ?
I am all too familiar with marshalling etc ) And I must confess that I took the plunge and wrote an analogue in C# on the grounds that it would have to be done one day !
Jerry
|
|
|
|
|
Just because something is written "in .NET" doesn't make it remotable. It has to extend MarshalByObjectRef or be a value type and be serializable (in most cases, attributed with SerializableAttribute ). Something has to host the remote object, too. For instance, just having a console app won't work. Now, a console app that registers a well-known object (WKO) either via code or a config file (latter is preferable for easy changes) and keeps itself running (waits for a quit command of sorts) would work. Clients would connect to that WKO.
The documentation about .NET remoting is okay, at least if you already have some idea of what it does. If you don't, I suggest you get the book from MSPress entitled .NET Remoting (at www.microsoft.com/mspress/books/6172.asp).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Sure but I was not asking about remoting. Can a .NET service invoke (using the Process class) a process written in unmanaged C++ but compiled to IL rather than native code ?
Jerry
|
|
|
|
|
The Process class can start any process executable, regardless of how it compiled (i.e., it doesn't matter if it is a VB executable, unmanaged C++, managed C++ or other from any other languages targeting the CLR, compiled PERL exectable, etc.).
Also, any C++ application compiled to IL is managed (save the purely native functions). You can't compiled to IL and have an unmanaged executable.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
The .NET Framework includes the base class library (BCL) and the common language runtime (CLR). The CLR just-in-time compiles (jit's) intermediate language (IL, or more specifically MSIL) and executes it. Languages that target the CLR (MC++, C#, VB.NET, J#, PERL.NET, etc.) compile to IL in the form of assemblies, which are executable files (.exe, .dll) that contain 0 or more modules (compiled code), 0 or more embedded resources, various assembly attributes, and a manifest (like a plane or boat passenger manifest) of all that stuff in the assembly. So, it doesn't matter which language you use they all compile to assemblies using IL.
Make yourself a Managed DLL project for MC++ and puts some classes into it. Make a Windows Forms application (or something) in C#. If both of these projects are in VS.NET in a single solution, right-click on the Windows Forms project and click Add Reference. Click the Project tab and select your other project. Otherwise, click the .NET tab and browse for the MC++ assembly. Use classes from the MC++ assembly and compile your app. Viola'!
This is - in essence - no different from library bindings in Win32 or any other programming platform. It's all in the docs!
Consider yourself educated - now go out and read the docs to further your education!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath. PLease see my reply to the previous post.
Jerry
|
|
|
|
|
I create setup program for distributed my application to client. The client computer doesn't have .Net 2003 and crsytal report. I have problem with crystal decision when I view report from my application. The computer must be install .Net 2003. But I don't want to install it. I already install .Net Framework 1.1, but it is still erorr. How to resolve that. I really thank you, if you guys can help me
|
|
|
|
|
Contact Crystal for a redistributable product license key.
I'd offer more information than that, but I wasn't the one that had to deal with Crystal Reports the last time we completed a project using it. It looks like you need to add the redistributable to your deployment project and add a custom property with the license key details.
|
|
|
|
|
somebodys can help me do that?
why i'm try delete it but occur an error "access denied" so that folder i had shared with full control for everyone
thanks!!!
Nho'c Ti`
|
|
|
|
|
Start by eliminating the possibilty that it is user related. Take a copy of the file and see if you can delete manually but using the same user that will the code runs as. If this works and the application still cannot delete another copy of the file, then it has to be code.
We would then need to see some source to find out why it doesn't work.
Al.
|
|
|
|
|
|
I'm having difficulty getting the Microsoft Application Block for Exception Management working. In particular, I'm trying to customize the DefaultPublisher so that it uses a custom log source in the EventLog.
Here are some of my constraints, many of which I've overcome.
1) I wanted the assembly deployed to the GAC so that more than one app could share it.
2) My apps are web apps, so I had to deal with security issues regarding getting a custom log source set up.
OK, so I created my strong names for the ExceptionManagement and Interfaces assemblies, and got both installed to the GAC. No problem. I used the INSTALLUTIL.EXE to run the custom installer for the ExceptionManagement assembly.
So far so good. I manually created the registry key and string value for my log source.
Next, I set up the web.config file. Here's the way I had it set up the first time:
<configSections>
<section name="exceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler, Microsoft.ApplicationBlocks.ExceptionManagement" />
</configSections>
<exceptionManagement>
<publisher assembly="Microsoft.ApplicationBlocks.ExceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher"
logName="Application" applicationName="My App Log Source" />
</exceptionManagement>
Now when I generated an exception, several were logged using my custom log source, including several that it was unable to find the type for the section handler. Well, I figured out that it was because I had an assembly in the GAC and hadn't fully qualified the names.
So I fixed the web.config to be:
<configSections>
<section name="exceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler,Microsoft.ApplicationBlocks.ExceptionManagement, System, Version=1.0.1404.32518, PublicKeyToken=d16c1e31f52ae760, Culture=neutral" />
</configSections>
<exceptionManagement>
<publisher assembly="Microsoft.ApplicationBlocks.ExceptionManagement"
type="Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher, System,
Version=1.0.1404.32518, PublicKeyToken=d16c1e31f52ae760, Culture=neutral" logName="Application" applicationName="My App Log Source" />
</exceptionManagement>
Well, now to the point I'm at now. I get an internal exception that has the following detail. I'm at wits end! Any help would greatly be appreciated!!!
Thanks,
Andy
1) Exception Information
*********************************************
Exception Type: System.Configuration.ConfigurationException
Message: Exception creating section handler. (E:\Users\All Users\Documents\Dev\dotNet\AcssExtranet\Web\web.config line 5)
BareMessage: Exception creating section handler.
Filename: E:\Users\All Users\Documents\Dev\dotNet\AcssExtranet\Web\web.config
Line: 5
TargetSite: System.Configuration.IConfigurationSectionHandler GetFactory(System.String)
HelpLink: NULL
Source: System.Web
StackTrace Information
*********************************************
at System.Web.Configuration.HttpConfigurationRecord.GetFactory(String configKey)
at System.Web.Configuration.HttpConfigurationRecord.Evaluate(String configKey, SectionRecord section)
at System.Web.Configuration.HttpConfigurationRecord.GetConfig(String configKey, Boolean cacheResult)
at System.Web.Configuration.HttpConfigurationRecord.GetConfig(String configKey, Boolean cacheResult)
at System.Web.HttpContext.GetConfig(String name)
at System.Web.Configuration.HttpConfigurationSystemBase.System.Configuration.IConfigurationSystem.GetConfig(String configKey)
at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)
at Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(Exception exception, NameValueCollection additionalInfo)
2) Exception Information
*********************************************
Exception Type: System.IO.FileNotFoundException
Message: File or assembly name Microsoft.ApplicationBlocks.ExceptionManagement, or one of its dependencies, was not found.
FileName: Microsoft.ApplicationBlocks.ExceptionManagement
FusionLog: === Pre-bind state information ===
LOG: DisplayName = Microsoft.ApplicationBlocks.ExceptionManagement, Culture=neutral, PublicKeyToken=d16c1e31f52ae760
(Partial)
LOG: Appbase = file:///E:/Users/All Users/Documents/Dev/dotNet/AcssExtranet/Web
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: Microsoft.ApplicationBlocks.ExceptionManagement, Culture=neutral, PublicKeyToken=d16c1e31f52ae760
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/extranet/742de6b4/69ece159/Microsoft.ApplicationBlocks.ExceptionManagement.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/extranet/742de6b4/69ece159/Microsoft.ApplicationBlocks.ExceptionManagement/Microsoft.ApplicationBlocks.ExceptionManagement.DLL.
LOG: Attempting download of new URL file:///E:/Users/All Users/Documents/Dev/dotNet/AcssExtranet/Web/bin/Microsoft.ApplicationBlocks.ExceptionManagement.DLL.
LOG: Attempting download of new URL file:///E:/Users/All Users/Documents/Dev/dotNet/AcssExtranet/Web/bin/Microsoft.ApplicationBlocks.ExceptionManagement/Microsoft.ApplicationBlocks.ExceptionManagement.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/extranet/742de6b4/69ece159/Microsoft.ApplicationBlocks.ExceptionManagement.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/extranet/742de6b4/69ece159/Microsoft.ApplicationBlocks.ExceptionManagement/Microsoft.ApplicationBlocks.ExceptionManagement.EXE.
LOG: Attempting download of new URL file:///E:/Users/All Users/Documents/Dev/dotNet/AcssExtranet/Web/bin/Microsoft.ApplicationBlocks.ExceptionManagement.EXE.
LOG: Attempting download of new URL file:///E:/Users/All Users/Documents/Dev/dotNet/AcssExtranet/Web/bin/Microsoft.ApplicationBlocks.ExceptionManagement/Microsoft.ApplicationBlocks.ExceptionManagement.EXE.
TargetSite: System.Type GetType(System.String, Boolean)
HelpLink: NULL
Source: mscorlib
StackTrace Information
*********************************************
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Web.Configuration.HttpConfigurationRecord.GetFactory(String configKey)
For more information, see Help and Support Center at
Andy Hochstetler
|
|
|
|
|
I'm using the callback function of RASDIAL (RASAPI32.DLL). It works just perfect: The RASDIAL call returns immediately and my callback function is called numerous times to process the progress/error messages. In order to wait for the successful connection, I wrote a WHILE-loop in my main class to wait for the "Connected" message. That's where I'm having problems: the Application.DoEvents() in my WHILE-loop causes a System.NullReferenceException followed by message telling me that there is no source code available at the current position. I learned that the DoEvents call is for single-threaded programming and I guess that the RasDial callback function probably introduces multiple threads. I found a workaround by using a Timer without DoEvents() but then I find myself left in the Timer-Event to go on with my app. Summary: I WANT TO USE DoEVENTS() or something equivalent! Can someone please help me out?
private void btnRasConnect_Click(object sender, System.EventArgs e) {
ras = new Dialup.RASDisplay();
uint retCode = ras.Connect(""); // RasDial with callback
if(retCode != 0) {
ras.DisplayRasError(retCode);
} else {
string tmpString = ras.GetLastMessage();
while((!tmpString.StartsWith("ERROR:")) &&
(tmpString != "Connected") &&
(tmpString != "Disconnected")) {
Application.DoEvents(); // **** causes abort in unknow module
tmpString = ras.GetLastMessage();
}
}
return;
}
public uint Connect(string varPhoneNr)
{
RASDIALPARAMS lprasdialparamsa = new RASDIALPARAMS();
FPtr myFunc = new FPtr(RasDialFunc);
lprasdialparamsa.szEntryName = m_ConnectionNames[0];
lprasdialparamsa.szPhoneNumber = varPhoneNr;
lprasdialparamsa.szDomain = "";
lprasdialparamsa.szUserName = "Administrator";
lprasdialparamsa.szPassword = "abcdefg";
uint retVal = RAS.RasDial(0,@"rasphone.pbk", ref lprasdialparamsa,0,myFunc, ref m_ConnectedRasHandle);
return(retVal);
}
public void RasDialFunc( uint unMsg, RASCONNSTATE rasconnstate, uint dwError ) {
string lpszMsg;
byte [] tmpBuf = new byte[256];
ASCIIEncoding encoding = new ASCIIEncoding();
string szStrBuf = encoding.GetString(tmpBuf);
if(dwError != 0) {
if ( RAS.RasGetErrorString( dwError, szStrBuf, 256 ) != 0 ) {
m_LastMessage = "ERROR: Undefined RAS Dial Error " + dwError.ToString();
}
else {
m_LastMessage = "ERROR: " + szStrBuf;
}
Disconnect();
return;
}
switch ( rasconnstate ) {
case RASCONNSTATE.RASCS_OpenPort: lpszMsg = "Opening Port";break;
case RASCONNSTATE.RASCS_PortOpened: lpszMsg = "Port Opened";break;
case RASCONNSTATE.RASCS_ConnectDevice: lpszMsg = "Connecting Device";break;
case RASCONNSTATE.RASCS_DeviceConnected: lpszMsg = "Device Connected";break;
case RASCONNSTATE.RASCS_AllDevicesConnected: lpszMsg = "All Devices Connected";break;
case RASCONNSTATE.RASCS_Authenticate: lpszMsg = "Starting Authentication";break;
case RASCONNSTATE.RASCS_AuthNotify: lpszMsg = "Authentication Notify";break;
case RASCONNSTATE.RASCS_AuthRetry: lpszMsg = "Authentication Retry";break;
case RASCONNSTATE.RASCS_AuthCallback: lpszMsg ="Callback Requested";break;
case RASCONNSTATE.RASCS_AuthChangePassword: lpszMsg = "Change Password Requested"; break;
case RASCONNSTATE.RASCS_AuthProject: lpszMsg = "Projection Phase Started";break;
case RASCONNSTATE.RASCS_AuthLinkSpeed: lpszMsg = "Link Speed Calculation";break;
case RASCONNSTATE.RASCS_AuthAck: lpszMsg = "Authentication Acknowledged";break;
case RASCONNSTATE.RASCS_ReAuthenticate: lpszMsg = "Reauthenticatation Started";break;
case RASCONNSTATE.RASCS_Authenticated: lpszMsg = "Authenticated";break;
case RASCONNSTATE.RASCS_PrepareForCallback: lpszMsg = "Preparation For Callback";break;
case RASCONNSTATE.RASCS_WaitForModemReset: lpszMsg = "Waiting For Modem Reset";break;
case RASCONNSTATE.RASCS_WaitForCallback: lpszMsg = "Waiting For Callback";break;
case RASCONNSTATE.RASCS_Interactive: lpszMsg ="Interactive";break;
case RASCONNSTATE.RASCS_RetryAuthentication: lpszMsg = "Retry Authentication";break;
case RASCONNSTATE.RASCS_CallbackSetByCaller: lpszMsg = "Callback Set By Caller";break;
case RASCONNSTATE.RASCS_PasswordExpired: lpszMsg = "Password Expired";break;
case RASCONNSTATE.RASCS_Disconnected: lpszMsg = "Disconnected";break;
case RASCONNSTATE.RASCS_Connected:
lpszMsg = "Connected";
m_connected = true;
break;
default: lpszMsg = "Noch nicht aufgenommener Fehler"; break;
}
m_LastMessage = lpszMsg + Environment.NewLine;
}
|
|
|
|
|
Some time ago, I found and downloaded a file that would convert files created by the two version from one to the other. Unfortunately, I have now lost it. Can anyone point me to it?
Prof. Lloyd
|
|
|
|
|