|
Sorry, I've never worked with it before, but perhaps this[^] will be of some assistance.
|
|
|
|
|
Add a (COM) reference to Microsoft DTSPackage Library in VS.
DTS.Package becomes DTS.Package2Class when you add the above reference. Other than that the code will only need the usual VB6-->C# changes.
VB6 was not strongly typed, so you may need to remember to cast objects appropriately when converting the above code to C#
I have done plenty of this so when you get specific problems post them back here and ill do my best to help.
|
|
|
|
|
I am finally getting back to working on this. I have completed the conversion of the VB6 to the C#. However, I am getting the following error:
System.InvalidCastException
and it is happening at this line of code
DTS.DataPumpTask DT = (DTS.DataPumpTask)package.Tasks.New("DTSDataPumpTask");
From what I have been able to find is that sp3 is need for SQL and I have that already.
I am just working on some test code right now and I can send you a copy of it if it helps.
|
|
|
|
|
Hey!
I have two classes: PortHandler and StreamForm.
StreamForm contains a RichTextBox and a button.
PortHandler is used to open a stream from a cellphone connected on COM1(seriallport).
When information is coming in PortHandler uses a delegate to write to the RichTextBox in StreamForm.
Here is how it looks like
StreamForm:
<br />
public delegate void IncomingPortData(object sender, string data);<br />
public IncomingPortData Incoming;<br />
<br />
private PortHandler PHandler;<br />
<br />
public StreamForm()<br />
{<br />
InitializeComponent();<br />
Incoming = new IncomingPortData(AddDataToLogg);<br />
}<br />
<br />
private void btConnectPhone_Click(object sender, EventArgs e)<br />
{<br />
connectPort();<br />
}<br />
<br />
public bool connectPort()<br />
{<br />
try<br />
{<br />
if (PHandler != null)<br />
{<br />
closePort();<br />
}<br />
<br />
PHandler = new PortHandler();<br />
PHandler.IncomingPortData = new PortHandler.PassPortData(IncomingData);<br />
<br />
if (PHandler.connectPort(new PortSettings("COM1", 19200, 8, Parity.None, StopBits.One)))<br />
{
return true;<br />
}<br />
return false;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - connectPort : " + ex.Message);<br />
return false;<br />
}<br />
}<br />
<br />
<br />
private void IncomingData(object sender, string data)<br />
{<br />
try<br />
{<br />
if (rtIncomeLogg.IsHandleCreated == false)<br />
MessageBox.Show("error here");<br />
<br />
rtIncomeLogg.Invoke(Incoming);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - IncomingData : " + ex.Message);<br />
}<br />
}<br />
private void AddDataToLogg(object sender, string data)<br />
{<br />
try<br />
{<br />
rtIncomeLogg.AppendText(data);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - AddDataToLogg : " + ex.Message);<br />
}<br />
}<br />
And the PortHandler
<br />
public delegate void PassPortData(object sender, string data);<br />
public PassPortData IncomingPortData;<br />
<br />
private SerialPort serialPort = null;<br />
private bool RUNNING = false;<br />
<br />
public bool connectPort(PortSettings settings)<br />
{<br />
try<br />
{<br />
if (serialPort == null)<br />
{<br />
PortConnection PCon = new PortConnection();<br />
serialPort = PCon.connectPort(settings);<br />
Thread IncomeThread = new Thread(new ThreadStart(IncomingData));<br />
IncomeThread.Priority = ThreadPriority.AboveNormal;<br />
RUNNING = true;<br />
IncomeThread.Start();<br />
return true;<br />
}<br />
return false;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - PortHandler - connectPort : " + ex.Message);<br />
return false;<br />
}<br />
}<br />
<br />
<br />
public void IncomingData()<br />
{<br />
try<br />
{<br />
string tmpString;<br />
<br />
while (RUNNING)<br />
{<br />
tmpString = ((char)serialPort.ReadChar()).ToString();<br />
<br />
if (tmpString.Length > 0)<br />
{<br />
IncomingPortData(this, tmpString);<br />
}<br />
tmpString = "";<br />
serialPort.ReadTimeout = 1000;<br />
}<br />
}<br />
<br />
Why is this dont working?
I get: Cannot call Invoke on a control until the window handler has been created?
This is a Windows Control Library(own made control.
I adds this Control to a simple Windows application project with a regular form with no extra code in.
But i get another error here?
<br />
namespace PortTest<br />
{<br />
static class Program<br />
{<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.EnableRTLMirroring();<br />
Application.Run(new MainForm());
}<br />
}<br />
}<br />
The error i get here i : Parameter count mismatch!
This error do not appare at the start, but when i am trying to write to the rich text box
Pleas help
|
|
|
|
|
As for the Invoke problem, it stems from the control's handle not being created at the time you use Invoke.
I cannot see where rtIncomeLog is instantiated and added to a form, but the form in which it is a child has probably not had enough time to load. Invoke uses the control's handle to dispatch the delegates. To fix this there are a few things you can do: Wait to receive your incoming data until the control has been properly loaded by listening to the Load event, or you can create a model for your textbox. With the model you can append text to it, then dispatch an event that the text has changed. If the log control has been created then you can append the text to it, if not just hold onto the text until the model changes again. It wont matter if you build up a buffer of text if the rtIncomeLogg hasn't been created, because you won't be able to see the text anyways.
I can't immediately help for the 'Parameter count mismatch' because you didnt provide a line number. If you could provide the line number and the surrounding code that produces this error, I might be able to assist you.
-
Drew
|
|
|
|
|
I am working on an application in C#.Net which will be displaying images which will have color spaces defined (sRGB, Adobe RGB, etc). How do I go about making use of the defined color space to display the image correctly?
|
|
|
|
|
I want to connect to a pc using my modem for some FTP. plzz tell me what to do on both ends?
Thnxx in advance, Be Safe
Rizwan
Rizwan Ahmed
|
|
|
|
|
Hi! I've got this event in a gradient class:
public event EventHandler GradientChanged;
which is called by this method when a member of the gradient class is changed:
protected virtual void OnGradientChanged(EventArgs args)
{
if (this.GradientChanged != null)
this.GradientChanged((object)this, args);
}
But when I try to subscribe to this event, I get the following error:
"Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located."
Any suggestions on how to fix it?
|
|
|
|
|
Could you post the line in which you attempt to assign a delegate?
You should be able to do something like the following:
<code>
{
theClass.GradientChanged += new EventHandler (OnGradientChanged);
}
public void OnGradientChanged (Object sender, EventArgs e)
{
}
</code>
-
Drew
|
|
|
|
|
Well.. I suspect that posting this doesn't help... I think the error might be somewhere else in my code, or in the .NET framework..
here's the code in three different versions that compiles perfect:
[no1]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += new EventHandler(colorGradient_GradientChanged);
}
[no2]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
}
[no3]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
}
|
|
|
|
|
_eulogy_ wrote:
[no1]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += new EventHandler(colorGradient_GradientChanged);
}
Is ColorGradient a class you have declared? If so, did you mark the event with the 'event' keyword?
What is the event type for GradientChanged? It could be something wrong somewhere else like you stated.
_eulogy_ wrote:
no2]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
}
This is definately not going to work
_eulogy_ wrote:
[no3]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
}
This might only work in C# 2.0, but I dont think you put the parameters for anonymous delegates in C# 2.0
-
Drew
|
|
|
|
|
The ColorGradient is a class I've made.. If I didn't mark GradientChanged with the event keyword I would get a compile time error. The gradient changed is an EventHandler (as you can see in no1)..
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
works as hell... It's a new syntax..
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
this also works as hell.. You have to put the parameters there, or else you can't access them!
I've found the problem though... It seems like it was caused by an inconsistency in how whidbey stores the gui objects created with the visual editor...
|
|
|
|
|
i got this Error when adding a component in my progect
"Failed to import the activeX control"
how can i solve this ?
|
|
|
|
|
I want to insert a hugh data table to oracle database. currently i use for loop to go throuh each row of table and use insert sql statement to insert row to oracle database.
Any one has ohter easy way to do this?
Thanks for help.
|
|
|
|
|
I have a string
str = "145.35" and want to convert it into a float value.
Float.Parse(str)
and the result is 14535.0
I tried some ways already but there must be a way to convert it correctly. Does anybody know a way out ?
|
|
|
|
|
You can always try Convert.ToSingle("145.35") ...
|
|
|
|
|
str is filled with an unknown value. 145.35 is an example only.
|
|
|
|
|
I was using "145.35" as an example as well. BTW, what is your locale? This does play a part into how the conversion routines try to to parse things. Is "." the decimal delimiter or the thousand delimiter for you?
ps. This does bring up an quirky point: Is Convert.ToSingle meant to be the IEEE supported float conversion while Single.Parse is the locale specific one?
|
|
|
|
|
It's the decimal one.
Single bring the same problem.
|
|
|
|
|
I've written a lot of code converting string values that are clearly "float like" and never had a problem. I guess the problem is deeper. I would investigate exactly what is the string you are feeding into it because I simply can't reproduce your problem. The only other thing I can think you are running into is some bad percision mojo but your example isn't sufficient to show it.
example code:
using System;
namespace tlarsen
{
public class test
{
public static int Main()
{
string s = " 145.35 ";
float f = Convert.ToSingle(s);
Console.WriteLine("s = " + s);
Console.WriteLine("f = " + f.ToString());
Console.WriteLine("1 + f = (should be 146.35) : " + (f + 1));
return 0;
}
}
}
|
|
|
|
|
Due to the local settings, application demands "," as delimeter not the "."
Now it works.
|
|
|
|
|
float.Parse(str) method should also work. Perhaps you might have committed some small mistake here and there. For testing it, create a new Windows Form project and place a button1 on that. In the click event-handler, put the following code:
private void button1_Click(object sender, System.EventArgs e)
{
string str = "145.35";
float x = float.Parse(str);
MessageBox.Show(x.ToString());
}
It works properly and the MessageBox shows the correct value of float variable as "145.35". If you use x in some expression such as x = x*2, again it will use the correct value. In the debug mode, when you check the value of x, again it shows the correct value. So please ensure that you use the proper coding, otherwise there is nothing wrong in the method.
|
|
|
|
|
Hi!
Is there a way of making a string html compliant (i.e. replacing german umlauts with the appropriate hex code), without hardcoding each character's translation.
|
|
|
|
|
Check out System.Web.HttpServerUtility.HtmlEncode(string)
Hope this helps
|
|
|
|
|
Thanks a lot! That was exactly what I meant. Although I must say that HttpServerUtility is only usable from within an ASP.NET application, for normal Windows apps HttpUtility has to be used.
|
|
|
|