|
Take a look at the CodeDomSerializer class, which you can use to persist a file that IntelliSense can parse. This is how code is generated from XSD files, Windows Forms controls and forms, etc.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hey
I have been looking into som article here on Codeproject about remoting.
There is some thing i dont understand realy.
I have tryed to make a object(from dll file) active(creat) by using remoting(SingleCall).
The client simes like it gets the object but its empty.(I know that the client is working)
How do i fill the object with info? I have tryed do creat the object on the server and add the info to it, but when the client request a remot obj it takes a new one.
I have thougt of writing the info in the dll file, but then i dont realy need the server to transfer it when all the info is already in the dll file on at the client. I could let the dll file open a file on the server an read info there but this dont simes right?
How do i let the server add information to the object that the client is geting info from?
Server Code:
hc = new HttpChannel(10034);
ChannelServices.RegisterChannel(hc); RemotingConfiguration.RegisterWellKnownServiceType(typeof(QuoteService.Quotes),"QuoteServer",WellKnownObjectMode.SingleCall);
Remote dll(QuoteService.Quotes):
Arraylist that stors objects of an other class(QuoteService.Quote) that also is : MarshalByRefObject
Client Code:
hc = new HttpChannel(); ChannelServices.RegisterChannel(hc);
QuoteService.Quotes quote;
Random ranobj = new Random();
quote = (QuoteService.Quotes)Activator.GetObject(typeof(QuoteService.Quotes),"http://localhost:10034/QuoteServer");
This problem is probely silly!
//Jimmy
|
|
|
|
|
NoOne that can explain how to creat object on server and give it serten values and then to let the client read the information that the server have stored in this object(dll file)
//Jimmy
|
|
|
|
|
i'm just looking for something quick and dirty, and doesn't have to be elegant or efficient. I will have a C# .EXE in one process that needs to get info from a C++ DLL. the quickest way to get something up and running would probably be just writing to a file and then reading it from the other process. or should i use named pipes or sockets? is there an easier way i'm missing? thanks
|
|
|
|
|
You aren't very clear as to the type of C++ dll that you have. Is it a C++ COM dll or a standard Win32 dll? What does the data look like that you need to get from the C++ dll? There are mechanisms such as P/Invoke that may work and there are also RCW's that you can explore - all depending on what type of dll it is. More information would be helpful in answering your question.
- Nick Parker My Blog | My Articles
|
|
|
|
|
it's a COM dll, but it will be loaded in a different process (of perhaps another exe) than the c# exe. information i'd be passing from the com dll to the C# exe would be simple strings.
|
|
|
|
|
Hi.
I have a program write in c# that fills a dataset from a access database and send it to a web services.
This web services has to update the data on a sql server.
The problem is the next every time i run the program this send the dataset to the webservices, but the webservices every time insert the information in a new row.
here is the code if you can help me.
[WebMethod(Description="Metodo para insertar DataSet")]
public string guarda(DataSet source)
{
int rows;
conn.Open();
SqlTransaction transac;
transac = conn.BeginTransaction();
SqlCommand sql_select = new SqlCommand("SELECT ccactual, DescCuenta, CCcpv, CuentaRealCPV, ctaactiva FROM cuentas", conn, transac);
SqlCommand sql_update = new SqlCommand("UPDATE cuentas SET ccactual=@ccactual, DescCuenta=@DescCuenta, CCcpv=@CCcpv, CuentaRealCPV=@CuentaRealCPV, ctaactiva=@ctaactiva WHERE ccactual = @ccactual_b", conn, transac);
SqlCommand sql_insert = new SqlCommand("INSERT INTO cuentas (ccactual, DescCuenta, CCcpv, CuentaRealCPV, ctaactiva) VALUES (@ccactual, @DescCuenta, @CCcpv, @CuentaRealCPV, @ctaactiva)", conn, transac);
SqlCommand sql_delete = new SqlCommand("DELETE FROM cuentas WHERE ccactual = @ccactual_b", conn, transac);
SqlDataAdapter da = new SqlDataAdapter();
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.AcceptChangesDuringFill = false;
da.SelectCommand = sql_select;
da.UpdateCommand = sql_update;
da.UpdateCommand.Parameters.Add("@ccactual", SqlDbType.VarChar, 10, "ccactual");
da.UpdateCommand.Parameters.Add("@DescCuenta", SqlDbType.VarChar, 50, "DescCuenta");
da.UpdateCommand.Parameters.Add("@CCcpv", SqlDbType.Int, 4, "CCcpv");
da.UpdateCommand.Parameters.Add("@CuentaRealCPV", SqlDbType.Int, 4, "CuentaRealCPV");
da.UpdateCommand.Parameters.Add("@ctaactiva", SqlDbType.Int, 4, "ctaactiva");
da.UpdateCommand.Parameters.Add("@ccactual_b", SqlDbType.VarChar, 10, "ccactual");
da.InsertCommand = sql_insert;
da.InsertCommand.Parameters.Add("@ccactual", SqlDbType.VarChar, 10, "ccactual");
da.InsertCommand.Parameters.Add("@DescCuenta", SqlDbType.VarChar, 50, "DescCuenta");
da.InsertCommand.Parameters.Add("@CCcpv", SqlDbType.Int, 4, "CCcpv");
da.InsertCommand.Parameters.Add("@CuentaRealCPV", SqlDbType.Int, 4, "CuentaRealCPV");
da.InsertCommand.Parameters.Add("@ctaactiva", SqlDbType.Int, 4, "ctaactiva");
da.DeleteCommand = sql_delete;
da.DeleteCommand.Parameters.Add("@ccactual_b", SqlDbType.Int, 4, "ccactual");
da.Fill(target,"cuentas");
target.Merge(source,true);
target.Tables["cuentas"].da
rows = da.Update(target,"cuentas");
transac.Commit();
conn.Close();
return rows.ToString();
}
Thanks
|
|
|
|
|
First, you really should wrap this in a try-catch-finally block, where you commit your transaction in the try, rollback in the catch, and close the connection in the finally.
Without knowing what the data in your DataSet has, you'll need to debug your code and look at the state of the DataSet (perhaps persist it to a file passing XmlWriteMode.DiffGram to easily view the DataRowState ). Make sure that the rows that should be updated have the DataRowState.Modified value.
Since you're merging these updated rows could look like new rows in the target DataSet .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Is there any possiblities to access all of the variables from a class dynamically (something like MyFriends.GetVariable("Name"); )?
fsadfasdfsadfasdfasdf
|
|
|
|
|
And is there some Information available for Regexps in C#?
I wasn't able to extract strings out of an other string with Regex.Match (e.g. /^([^=]+)=(.+)$/ - should extract key and value of a "key=value" pair...)
(I just edited my account options)
|
|
|
|
|
Here on MSDN[^] are some information about regular expressions.
As for your example, I would use stg like (?<key>.*?)=(?<value>.*)
TyronX wrote:
(I just edited my account options)
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
You can use reflection to enumerate types and their members (properties, fields, and methods). Read Discovering Type Information at Runtime[^] in the .NET Framework SDK.
Note that these aren't "variables". Variables - in practically any language - are temporary memory addresses to store information in a particular function or method (methods are functions declared for a class or other structure). You can also have global variables.
To enumerate properties on a class, for example (since you typically shouldn't expose fields publicly; you have little control over what gets assigned and can't validate the data):
using System;
using System.Reflection;
class Person
{
static void Main()
{
Person p = new Person("Heath", DateTime.Parse("08/07/1978"));
Reflect(p);
}
static void Reflect(Person p)
{
PropertyInfo[] props = p.GetType().GetProperties(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (props != null)
{
foreach (PropertyInfo prop in props)
{
object value = prop.GetValue(p, null);
Console.WriteLine("{0} ({1}) = {2}", prop.Name, prop.PropertyType,
value);
}
}
}
Person(string name, DateTime birthday)
{
this.name = name;
this.birthday = birthday;
}
string name;
DateTime birthday;
public string Name
{
get { return name; }
set
{
if (value == null) throw new ArgumentNullException();
name = value;
}
}
public DateTime Birthday
{
get { return birthday; }
set { birthday = value; }
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I created a Monthly Calendar where each day cell is a Label. I have implemented the Click event to highlight the day and the DoubleClick event to call the day view for the selected day for each label. The problem is that when the DoubleClick event is fired it first goes through the Click event.
How do I distinguish between the two events?
Thanks
|
|
|
|
|
|
the following lines cause a invalid parameter exception in the last line and i'am not sure where my mistake is. Does anybody see the error?
Help is much appreciated.
thank you
Bernd
GraphicsPath gp = new GraphicsPath();
gp =(GraphicsPath)pfadListe[0];
int punktAnz = gp.PointCount;
PointF [] punkte = new PointF[punktAnz];
punkte = gp.PathPoints;
|
|
|
|
|
The first problem (not error) I notice are these two lines:
GraphicsPath gp = new GraphicsPath();
gp =(GraphicsPath)pfadListe[0]; Why are you instantiating the class if you just assign it later (in fact, in the next line)? Either declare (not instantiate) and assign on separate lines, or declare and assign on the same line like so:
GraphicsPath gp = (GraphicsPath)pfadListe[0]; What line does the exception actually get thrown on? Debug your code and be specific. Also, there is no "invalid parameter exception", or even a class called InvalidParameterException . What is the exact type of exception thrown?
My initial guess is that either pfadListe is empty and trying to access the first element via [0] would result in an IndexOutOfRangeException<?code> or that whatever is in the first element of the array cannot be cast to <code>GraphicsPath , in which case an InvalidCastException is thrown.
Please be specific.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
thanks for the tip with the first two lines. i am more a hobby-programmer, i guess.
the exception is thrown in the last line, as i said before.
punkte = gp.PathPoints;
heres the statement i get:
************** Exception Text **************
System.ArgumentException: Invalid parameter used.
at System.Drawing.Drawing2D.GraphicsPath.get_PathPoints()
at DefaultNamespace.MainForm.convToCardSpline(ArrayList pfadListe) in e:\Eigene Dateien\SharpDevelop Projects\CurveGenerator\MainForm.cs:line 174
at DefaultNamespace.MainForm.MenuItem1Click(Object sender, EventArgs e) in e:\Eigene Dateien\SharpDevelop Projects\CurveGenerator\MainForm.cs:line 199
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.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, I
|
|
|
|
|
You're right, you did say "last line" (I could swear it said "following lines" before).
The exception here is actually ArgumentException and is most likely thrown because whatever your pfadListe contains - or rather how it got filled - does not contain valid data in the PathPoints property. That is, the GraphicsPath either doesn't contain enough data or contains invalid data, so when you try to get PathPoints it's implementation throws an ArgumentException .
There are many reasons this could happen (.NET 1.1 will throw 1 of 21 exceptions based on the error code returned by the native API GdipGetPathPoints ).
Basically, you don't have enough information and need to make sure that the GraphicsPath has enough data to return you the PathPoints .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
first: thanks for your time and helping me.
i appreciate that.
You're right. There is something wrong with tha graphicsPath-Data. I am not sure what this could be.
Is there a problem with storing a GraphicPath-Structure in an ArrayList? Because that is what pfadListe is.
I draw some paths with the mouse on the screen and store them in an ArrayList. Afterwards i wanna do some transformation with the paths.
|
|
|
|
|
I just stored the GraphicsPath-Object in the ArrayList as a reference, what was not clear to me.
so, when i did a reset on the path to store the next drawing-action in it, i also deleted the data in the pfadListe.
shame on me.
|
|
|
|
|
Hello, I have a question. I have a 2D array [372,4], the first bit looks like this:
0.07 0.11 0.21 0.34
1.12 0.77 1.17 1.1
0.24 0.11 0.21 0.37
2.53 2.11 3.24 3.07
0.69 0.49 0.32 0.52
2.04 1.72 2.26 2.01
0.01 0 0 0.06
I would like to add the columns together so I get one single column. If I had a fixed array of the size I mentioned, I would not have a problem, it would look something like:
FD[i]=FD[i,0]+FD[i,1]+FD[i,2]+FD[i,3]
no problem. However, I would like to be able to have a variable for my number of columns, so then my summation would look something like:
FD[i]=FD1[i,0]+FD1[i,1],FD1[i,2]+.....+FD1[i,n-1]+FD1[i,n]
and I am not sure how to or if it is possible to program this. Any clues? Thanks a bunch!!
|
|
|
|
|
Use a list like an ArrayList for each line, then enumerate the list and keep a running sum. How you do that you need to explore, being that this looks like a class problem that you need to figure out and understand.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Where can I find information on this? This is a project for my job. I am learning to program as I go.
|
|
|
|
|
http://msdn.microsoft.com/netframework[^]. For all SDK documentation go to http://msdn.microsoft.com/library[^]. If you've installed Visual Studio .NET with the default settings, the .NET Framework SDK is also installed and you should have a "Microsoft .NET Framework SDK" program group under Start->Programs which you can read, too.
All you need to do is look-up ArrayList (or IList to see other implementations) and read the documentation. If you're new to programming with .NET, I suggest you pick up a good book that teaches .NET and OO design and browse the Class Library[^] to get a glimpse of all the available classes in the .NET BCL (base class library).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
an article from Joel Brandenberger, which discrips how to use simple Remoting, but there are questions ...
first the link to the article:
http://codeproject.com/csharp/RemotingWinApp.asp[^]
he uses 3 projects:
- a Server Application
- a DLL with the Interface declaration
- a Client Application
in this case it works fine but this project is designed for an local or an intranet application...
i need a way to use it at the internet.
i know it would work too, but i have to copy the DLL with the Interface declaration to all Clients.
My ServerApplication should be able to load unknown DLLs and provide them with remoting. So its not user friendly to copy new DLLs to the ClientApplication for every changing on the ServerApplication...
I thought of a possibility to load DLLs over Internet ...?
like
LoadDLL(http://server.tld/Application/AddOns/Interface.dll)
i hope you understand my problem, if not ask ^^
Copyrights © 2003 by Paebbels.net
|
|
|
|
|