|
On what line? What does your code look like? Please be more specific. I can't help you if you just give me tidbits of information. Why do you think doctors want you to come in in order to diagnose problems, besides charging you money (which we don't do here, so that's even more incentive to be verbose).
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 am really sorry for not elaborating the scenario.
Below are the details.
Steps resulting error
1. I. Open TextPad / MS Word, II. write text III. Copy the content in the clipboard
2. I. Run the C# Application II. Call the method
3.Causes Runtime eroor at Clipboard.SetDataObject(oldData) line ;
4. Error Details :
System.Runtime.InteropServices.ExternalException : The requested clipboard operation failed.
Code :
private void PasteImg(RichTextBox richTextBox1, string imageFileName)
{
IDataObject oldData = Clipboard.GetDataObject();
#region Pasting the image
if("" == imageFileName) imageFileName = @"c:\JayShared\music.bmp";
Bitmap myBitmap = new Bitmap(imageFileName);
Clipboard.SetDataObject(myBitmap, false);
DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);
if(richTextBox1.CanPaste(myFormat))
{
richTextBox1.Paste();
}
#endregion Pasting the image
Clipboard.SetDataObject(oldData);
}
|
|
|
|
|
Jay Shankar wrote:
It works fine. But I want to restore the previous clipped data.
Well, I'm not sure if that's your problem but when I execute your code I get a COMException (Error HRESULT E_FAIL has been returned from a call to a COM component) after Clipboard.SetDataObject() has been called but that might be due to the .NET Framework 2.0 (no, I don't have a version 1.x installed ). Anyway. It should work fine when you replace the first two line with:
IDataObject prevDat = Clipboard.GetDataObject();
This is also how it's done in the code sample in the Visual Studio Documentation (see Clipboard.GetDataObject Method[^]). Please let me know if this hint solves your problem.
Best regards
Dennis
|
|
|
|
|
Dear Dennis,
Thanks a lot for your reply. I modified the function as par suggestion by you and Mr. Heath. But could not achieve the goal. Still trying....
Regards,
Jay
|
|
|
|
|
I'm looking to drive a class definition off of a configuration file and make the properties be definied through code using the PropertyBuilder class in Reflection. The one thing we can't figure out is if we can make the dynamic properties available in intellisense or even in code. Our goal is to make the dynamic class appear as a static coded class, so all the intellisense features are available. I assumed shadowing GetType() would do it and force VS.NET to use the correct type def, but it doesn't appear to work.
Does anyone have any thoughts on how to make it work. Is there a method we can override that VS.NET uses to introspect the object?
|
|
|
|
|
You will need to to reference the generated assembly in the project. That should allow intellisense to pick up the classes. If the code is generated and incorparated into the build, then just adding the generated files should be enough. Look how xsd -> cs is done.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
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.
|
|
|
|
|