|
If you've established a relationship between Customer and Order tables, this adds a relational-integrity constraint such that the Order table has a foreign key relationship with Customers; therefore, you cannot have a key in the Orders table that does not correspond to a primary key in your Customers table.
As far as programmatically removing the relationship or constraint, you could either do that (not much choice! ) or have two strongly-typed DataSet classes. We usually take the latter approach in our app I designed at work. Just makes things easier in the long-run and doesn't add too much bloat to your app/library.
-----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-----
|
|
|
|
|
I have created a dll in VC++ for customizing a dialog, and now I want to use this from my C# app. But I keep getting an error telling me that an entrypoint can't be found. So I guess I missed out on something when creating my native dll.
What I've done is simply create a new Win32 Dynamic-Link-Library project(MyDll.dll)
This adds the __declspec(dllexport) before the functions.
Then I build my project and copy the dll file into the working directory of my C# project.
The C# code for calling the dll function looks like this:
[DllImport("MyDll.dll")]
public static int sum(int x, int y);
So can anyone help me with why the entrypoint can't be found? Is there more to creating a native dll than this?
I really can't find any useful information for solving this anywhere (at least not useful to me...)
|
|
|
|
|
You can specify the entry point of your code within the DllImport attribute (Specifying an Entry Point[^]), also you need to identify your DllImport attribute with extern .
[DllImport("MyDll.dll", <code>EntryPoint="Sum"</code>)]
public static <code>extern</code> int sum(int x, int y);
- Nick Parker My Blog
|
|
|
|
|
why not create a managed C++ layer directly in the dll?
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Nick is write that you should include the extern keyword in the P/Invoked method declaration:
[DllImport("MyDll.dll")]
public static extern int sum(int x, int y); Also make sure that MyDll.dll is in a directory in the PATH environment variable or the application directory so that it can be found. Examples of such directories are C:\Windows, C:\Windows\System32, etc.
I just wanted to add that you can use depends.exe to make sure your functions are exported as you think they should be. Depends is a great Platform SDK tool and, if you choose the default options when installing VS.NET, should be installed. Just run the "Visual Studio .NET Command Prompt" in your VS.NET programs group off the start menu, cd' to the directory with your native DLL, and type "depends.exe MyDll.dll". If you've added the Platform SDK's bin directory to your system or user PATH environment variable (I like to manage all my PATH, INCLUDE, and LIB directories like this), you can just type "depends" in your Start->Run prompt and load your DLL. That will show you your exports.
-----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-----
|
|
|
|
|
Ok, thanks for the advice. so i checked the exported functions with the depends.exe tool, and they seem kind of odd...
the name of my sum(int, int) function is not sum, but rather appears as :
?sum@@YAHHH@Z
in the list over exported functions. No wonder the entry point can't be found I guess...
Do you have any idea what might cause this?
|
|
|
|
|
That's what happens when the function is not declared as a C-style function. The best way to declare the function is like so:
#ifdef _cplusplus
extern "C" {
#endif
INT __declspec(dllexport) sum(INT, INT);
#ifdef _cplusplus
}
#endif
INT __declspec(dllexport) sum(INT a, INT b)
{
return a + b;
} extern "C" declares the functions in the scope with C linkage and the functions won't be decorated. __declspec(dllexport) is a MS calling convention that exports the functions, thus eliminating the need for a .dep file. If you don't use this calling convention, you will have to use a .dep file.
-----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-----
|
|
|
|
|
I want to test my web service so I locate it in other computer(with IIS installed and .NET framework),and then create virtual directory in IIS for it and give read and browse directory permission,But when I run a test client and call the web service I HTTP error 405(Method not allowed) ,when I browse the WB from IE the test page does not appear and only a tag appear which say:
<%WebService Language=C# Code-Behind=.....>
Any idea?
Mazy
No sig. available now.
|
|
|
|
|
Sounds like the mappings for ASP.NET files are setup. Run "aspnet_regiis.exe -i" on the machine with ASP.NET installed using the framework you want to easily setup the appropriate mappings (like .aspx, .asmx, etc.). Run "aspnet_regiis.exe -?" for more information.
-----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-----
|
|
|
|
|
I want to test distributed application on local machine Before deploying the application
What is the tools that can simulate distributed enviroment ?
And is Microsoft Application Center Test can help in that?
Thanks in advance
|
|
|
|
|
Yes, ACT is for such a purpose. You can also throw together a simple client that spawns several threads all chattering with the distributed app. That's pretty much what all load-testing tools do. If you need to simulate different clients (ex, with different IPs) that gets a little more difficult but not impossible.
-----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
one more question
in your experience is the test result accurate?
in the case the test scenario related to the real environment
or i need to test again on real environment
thanks in advance
|
|
|
|
|
I'm sorry, but I couldn't tell you. I haven't had the opportunity to test it. I can tell you that lots of people use it, which wouldn't be the case if it were too bad.
-----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
i moved toward distributed application so you may find
me ask many qoustion about this topic
so any suggestion will be appreciated
thanks agai
|
|
|
|
|
Hi everyone
I have a problem when i try to read from database. the exception message says
Unspecified error: E_FAL_(0x80004005)
any one can help me?
The code is included in this file
the source code is also here
-----------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace blood
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Data.OleDb.OleDbCommand oleDbCommand1;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.label2});
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(424, 64);
this.panel1.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(225, 24);
this.label2.Name = "label2";
this.label2.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.label2.Size = new System.Drawing.Size(174, 13);
this.label2.TabIndex = 1;
this.label2.Text = "ÇáÑÌÇÁ ßÊÇÈÉ ßáãÉ ÇÓã ÇáãÓÊÎÏã æ ßáãÉ ÇáãÑæÑ";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(16, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(48, 48);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(283, 105);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(54, 13);
this.label3.TabIndex = 1;
this.label3.Text = "ÇÓã ÇáãÓÊÎÏã";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(289, 145);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(48, 13);
this.label4.TabIndex = 2;
this.label4.Text = "ßáãÉ ÇáãÑæÑ";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 101);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(63, 141);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(200, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "";
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(272, 189);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 5;
this.button1.Text = "ÏÎæá";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// oleDbCommand1
//
this.oleDbCommand1.CommandText = "SELECT id, name, [password] FROM names WHERE (id = ?) AND ([password] = ?)";
this.oleDbCommand1.Connection = this.oleDbConnection1;
this.oleDbCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("id", System.Data.OleDb.OleDbType.VarWChar, 15, "id"));
this.oleDbCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("password", System.Data.OleDb.OleDbType.VarWChar, 15, "password"));
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=muneer.mdb;Persist Security Info=Fal" +
"se;\0";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 230);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox2,
this.textBox1,
this.label4,
this.label3,
this.panel1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ÏÎæá";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
string sql = "SELECT id, name, [password] FROM names WHERE (id ='"+textBox1.Text+"') AND ([password] ='"+textBox2.Text+"')";
try
{
OleDbDataReader objReader;
//oleDbCommand1.Parameters["id"].Value = textBox1.Text.Trim();
//oleDbCommand1.Parameters["password"].Value = textBox2.Text.Trim();
oleDbConnection1.Open ();
oleDbCommand1.CommandText = sql;
objReader = oleDbCommand1.ExecuteReader();
if(objReader.Read())
{
//ss = objReader["name"].ToString();
objReader.Close();
this.Close();
}
}
catch(ArgumentNullException ex)
{
MessageBox.Show(this,"Error 4"+ex.Message,"Error...");
}
catch(Exception ex)
{
MessageBox.Show(this,"Error 3 "+" \n"+ex.Message,"Error...");
}
finally
{
oleDbConnection1.Close();
}
}
}
}
-----------------------------------------
|
|
|
|
|
|
Hi, my slave-working is making a irc plugin for my c# program in vb...i want to embed the dll in my project so others can't ripoff the component from the program folder...
Is their any way to achieve this?...or perhaps some way to compile two differant projects with two differant languages together resulting in one exe?
|
|
|
|
|
|
Hi, my slave-working is making a irc plugin for my c# program in vb...i want to embed the dll in my project so others can't ripoff the component from the program folder...
Is their any way to achieve this?...or perhaps some way to compile two differant projects with two differant languages together resulting in one exe?
|
|
|
|
|
|
First of all, what's wrong with just shipping an extra DLL? So long as you don't use the registry and rely instead on .config files (which is what you're supposed to do), you don't have to worry about elaborate installations, hence the "xcopy" deployment term, describing .NET's touchless deployment capabilities.
Second, don't embed it as a resource. If you mean VB.NET (instead of VB), there is a way to do it and handle AppDomain.AssemblyResolve but this is a HUGE waste of time and just isn't proper.
You can also compile two modules compiled from different source languages like C# and VB.NET and merge them into a single assembly. Compile one or the other using the target "module". I would recommend that you do this for the VB.NET project. Then, when you compile the other app into an assembly, you use /addmodule to reference the other module and link it into the assembly:
vbc.exe /t:module /out:Plugin.dll *.vb
csc.exe /t:exe /addmodule:Plugin.dll /out:App.exe *.cs See the compiler documentation or type "csc.exe /?" or "vbc.exe /?" to see more information.
Seriously, though, you'd gain a lot more flexibility by having your exe and dll separate, especially if you want to include more plugins through a .config file. There are several articles here on CP about plug-in architectures. Try a search[^] for examples.
-----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-----
|
|
|
|
|
I'm building a form so that customer can fill in their data (with a lot of texboxes). I decided to use datagrid. I don't know if I'm on the right track. I was able to build a array of datagrids programmactically. Here is my situation.
From : mm/dd/yy
To: mm/dd/yy
Fill (button)
Grid1 (all of these grids are built programmatcally and added into a placeholder)
Grid2
Grid3
...
Because there are 2 columns From and To
From : mm/dd/yy (<--- user will fill here) (**)
To: mm/dd/yy (<--- user will fill here) (***)
Grid1
From To A B C
blank blnk (user will fill here) (user will fill here) (user will fill here)
....
I want to assist user to fill the date they enter at (**) into the From column of the grid for them. I don't know what to do. I tried to write a piece of code for the button fill above but I failed.
Help me if you can. Thanks
protected System.Web.UI.WebControls.DataGrid[] grids;
public void fill (object sender, System.EventArgs e)
{
string from = frombox.Text;
string to = tobox.Text;
foreach(DataGrid grid in grids)
{
foreach(DataGridItem item in grid.Items)
{
Response.Write("Found");
//TextBox tb = (TextBox)item.Cells[1].FindControl("answerbox");
//string str = tb.Text;
//ls.Add(str);
}
}
}
Errror
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 214: Response.Write("Control not found");
Line 215: }*/
Line 216: foreach(DataGrid grid in grids)
Line 217: {
Line 218: foreach(DataGridItem item in grid.Items)
|
|
|
|
|
HI
Yesterday i had it, but couldnt replicate it, but now I have pin-pointed it.
BUG description: When rendering non-monospaced fonts, DrawString "compresses" the last +-25% of the string that need to be drawn. This can be seen clearly especially with long repetitive strings.
Here is a Control that demonstrates the BUG. Note: the alignment in the 1st 75% is "strected" and the rest is "squashed". Also that the complete width seems to be correct in SansSerif fonts, but not in Serif fonts.
[EDIT] If one clearly define the TextRendering not to use a GridFit type rendering, then it works correctly. Now where did I they leave the ClearTypeNonGridFit option? IMO it bad to change the underlying system's rendering as in the case if you have ClearType enabled. [EDIT]
[INFO] http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q307208[^] [INFO][EDIT] I still dont see how thats gonna solve my problem as it appears MeasureString is the cultprit.[EDIT]
Comments welcome (especially from the MS crowd).
class Drawer : Control
{
StringFormat sf = StringFormat.GenericTypographic;
public Drawer()
{
Text = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
BackColor = Color.White;
Font = new Font(FontFamily.GenericSerif, 24);
}
protected override void OnPaint(PaintEventArgs e)
{
float h = Font.GetHeight();
float w = e.Graphics.MeasureString("f", Font, int.MaxValue, sf).Width;
for (int i = 1; i <= Text.Length;i++)
{
e.Graphics.DrawLine(Pens.DimGray, w * i, 0, w * i, h);
}
for (int i = 1; i <= Text.Length;i++)
{
w = e.Graphics.MeasureString(Text.Substring(0, i), Font, int.MaxValue, sf).Width;
e.Graphics.DrawLine(Pens.DimGray, w , h, w, h + h);
}
e.Graphics.DrawString(Text, Font, Brushes.Black, 0,0, sf);
}
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
MS employee: Lets smoke more pot!
This is absurd:
"The default action of DrawString works against you when you display adjacent runs: First, the default StringFormat object adds an extra 1/6 em at each end of each output; second, when grid fitted widths are less than designed, the rendered string is allowed to contract from its measured size by up to an em.
To avoid these problems, do the following:
Always pass MeasureString and DrawString a StringFormat object based on the typographic StringFormat (GenericTypographic).
-and-
Set TextRenderingHint graphics to TextRenderingHintAntiAlias."
It still doesnt answer why MeasureString should return incorrect values...
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I read a book about c# called<microsoft visual="" c#="" core="" reference="">. I find delegate is harder to master than c++'s pointer... I dont know why everybody say that c# is easier to use than c++. sigh...
|
|
|
|
|