|
I can't tell what is wrong in your P/Invoke code as you aren't showing any of it.
I could guess your problem is one of these:
1. access right problems, Vista/Win7 being more protective of system resources than XP is.
2. Your Win7 probably is 64-bit, whereas your other systems probably are 32-bit, which means your P/Invoke must now correctly handle pointers, e.g. be aware that IntPtr is 32/64 bit depending on OS, whereas a lot of P/Invoke examples wrongly use int to pass pointers. (One way to circumvent this problem is by building for "x86" rather than "AnyCPU").
|
|
|
|
|
Luc Pattyn wrote: I can't tell what is wrong in your P/Invoke code as you aren't showing any of it. The code is same not a bit change from the article i mention i.e. Use PI invoke for serial communication.
Updated code is in download link of article, on MSDN(article) page code is not updated.
In case of not working modem ReceiveThread() of CommBase.cs is not behaving as its in working modem.
eventMask = (uint)Marshal.ReadInt32(uMask);
if ((eventMask & Win32Com.EV_RXCHAR) != 0)
{
do
{
gotbytes = 0;
if (!Win32Com.ReadFile(hPort, buf, 1, out gotbytes, unmanagedOv))
{
int x = Marshal.GetLastWin32Error();
throw new CommPortException("IO Error [004]");
}
if (gotbytes == 1) OnRxChar(buf[0]);
} while (gotbytes > 0);
}
uint i = 0;
if ((eventMask & Win32Com.EV_CTS) != 0) i |= Win32Com.MS_CTS_ON;
if ((eventMask & Win32Com.EV_DSR) != 0) i |= Win32Com.MS_DSR_ON;
if ((eventMask & Win32Com.EV_RLSD) != 0) i |= Win32Com.MS_RLSD_ON;
if ((eventMask & Win32Com.EV_RING) != 0) i |= Win32Com.MS_RING_ON;
if (i != 0)
{
uint f;
if (!Win32Com.GetCommModemStatus(hPort, out f)) throw new CommPortException("IO Error [005]");
OnStatusChange(new ModemStatus(i), new ModemStatus(f));
}
above are few lines of ReceiveThread for reference which are not executing as excepted.
Luc Pattyn wrote: Your Win7 probably is 64-bit, Its 32 bit.
Luc Pattyn wrote: (One way to circumvent this problem is by building for "x86" rather than "AnyCPU"). This i will try. But have doubt as same code is working in same window 7 but with different card.
But not working card respond with .Net 2.0 serial port class under same window 7.
|
|
|
|
|
Hi
I have problems with data source.
In my solution I have two project:
1) DataObject project
2) Application Project
In DataObject Project I have all data objects that I need. Yesterday I add new object to PayObject.xsd file in DataObject Project.
But I can’t see this new data member in my BindingSource property in Application project.
It seem that my Application Project don’t see this new data object, that I add and he only see’s old data members.
I try to rebuild whole solution and project a part, but result is same.
Thanks for your help.
|
|
|
|
|
Hi,
First clean the project then after built the project.
|
|
|
|
|
yes
I did it, but result is same.
|
|
|
|
|
Hi,
remove that reference , clean your bin directory of DataObject project and build after reference it.
that my resolve your issue. sometimes VS cache reference information
thanks
-amit.
|
|
|
|
|
Thanks amit.
I did as you say and it works as it should be.
thanks for help.
|
|
|
|
|
Hi all,
In my project i want to create a help file that is .chm file which is similar to the help file when you press F1.
How can i do this ? Is there any free software ?
Thanks in advance.
|
|
|
|
|
|
Use vizaac Helpmaker
Thanks & Regards
Pete
|
|
|
|
|
Has anybody found a way to add a user setting at runtime? I know its not really designed for that, but I'm trying to automate the upgrade process in my app and need to add a setting. I know I am allowed to add app settings and could use those in a more complicated way, but I'd really like to do it with the user settings since the way those work will do half my job for me .
Tried doing something like:
b.Properties.Add(new SettingsProperty("Testing", typeof(string), null, false, null, SettingsSerializeAs.String, null, false, false));
b.PropertyValues.Add(new SettingsPropertyValue(new SettingsProperty("Testing")));
b.PropertyValues["Testing"].PropertyValue = "Blah";
but it doesn't get written out and when I iterate through the props, I get an exception in .Net. I don't really care if the property shows up in the designer.
|
|
|
|
|
I found this on stack overflow, and it is a vb.net answer, but it may help you out. I haven't tried it myself.
http://stackoverflow.com/questions/175726/c-create-new-settings-at-run-time[^] This answer is about 2/3 down the page.
Just in case that still matters to anyone:
You can dynamically add settings through Settings.Default.Properties.Add(...) and have these also persisted in the local storage after saving (I had those entries reflected in the roaming file).
Nevertheless it seems that the dynamically added settings keep missing in the Settings.Default.Properties collecion after loading again.
I could work around this problem by adding the dynamic property before first accessing it. Example (notice that I "create" my dynamic setting from a base setting):
var property = new SettingsProperty(Settings.Default.Properties["<baseSetting>"]);
property.Name = "<dynamicSettingName>";
Settings.Default.Properties.Add(property);
var dynamicSetting = Settings.Default["<dynamicSettingName>"];
I don't know if this is supported by Microsoft as the documentation is very rare on this topic.
Problem is also described here http://www.vbdotnetforums.com/vb-net-general-discussion/29805-my-settings-run-time-added-properties-dont-save.html#post88152 with some solution offered here http://msdn.microsoft.com/en-us/library/saa62613(v=VS.100).aspx (see Community Content - headline "How to Create / Save / Load Dynamic (at Runtime) Settings"). But this is VB.NET.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Thanks for the link. I saw that one... didn't really like it and it wouldn't work for me since it would require the developer to do something before my code could work . Anyways, I figured it out:
SettingsAttributeDictionary attrDict = new SettingsAttributeDictionary();
UserScopedSettingAttribute attr = new UserScopedSettingAttribute();
attrDict.Add(attr.GetType(), attr);
SettingsProperty p = new SettingsProperty("Testing", typeof(bool), b.Providers["LocalFileSettingsProvider"], false, false, SettingsSerializeAs.String, attrDict, false, false);
b.Properties.Add(p);
b is the ref to the settings class... i.e. WpfApplication.Properties.Settings.Default;
the thing I was missing before was adding the attribute dictionary and the provider. One kinda-pita aspect of it is you need to add the setting every time so the setting provider knows about it. When you add it back after its in the setting file, it'll read the proper value out of it. It just doesn't add the key by itself because its not in the app.config, but I'm ok with that as I kind of like the aspect that the setting is "hidden".
|
|
|
|
|
My question is: How can I make a lamp turn out and turn on trough network with c#.
|
|
|
|
|
|
I think you may have to write code in embedded c.
|
|
|
|
|
I have an SSIS package that run dynamially using a c# script How can I retrieve values from the dtsconfig file? Currently I have hard codes the database connection and the paths. The file will run outside SQL Server 2008 as .dtsx.
|
|
|
|
|
|
Don't post this here - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Saving isn't explained in the article.
The article holds it's own forum; the original author will receive a copy of your question if you post it there. FWIW, it seems that you can Serialize a Macro.
Bastard Programmer from Hell
|
|
|
|
|
|
Don't repost the same question - edit your existing one if you want to add information.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Rajesh B --> A Simple Programmer <--
|
|
|
|
|
How the compare the the data entered in textbox with the items inserted in lisbox ? if data matches proceed to next from
|
|
|
|
|
A ListBox contains a collection of object s available under the Items property which can be enumerated with foreach . The only problem is that they are objects, and what is dispayed textually comes from each object's ToString method.
If you have put plain strings in the list then you can do a foreach like:
foreach(object item in listBox.Items)
if((string) item == textbox.Text)
If they are other objects then you will need to cast to that type and check the resulting instance for the string in whatever way is correct for you (a property, ToString() etc).
|
|
|
|