|
before rebuild my project its work properly But if rebuild it then gives error for each form.
The error is -
Unable to copy file "obj\Debug\Hospital.frmAddMedicine.resources" to "obj\Debug\Hospital.obj.Debug.Hospital.frmAddMedicine.resources". Could not find file 'obj\Debug\Hospital.frmAddMedicine.resources'. Hospital
But before rebuild the project all the resource file was present. Please help me.
|
|
|
|
|
Clean then rebuild.
maybe you have a couple of files' attributes set to read-only.
you can get rid of the obj folder each time you rebuild, no worry.
|
|
|
|
|
I am developing an sms application, whenever the application receive an sms it is assigned to a string. the string value is something like this:
+CMT:"+658208342",,"09/02/08",16:15:22+50"<br />
Test Message from coder
String text = (above code lines)
i have to take the Mobile number, datetime , and text as 3 different string from the above string.
Now what i had is that i use split whenever a string have " and then add it to an array
string s = text.Replace(",,", "");
string[] values = s.Split(new char[] { '"' });
string incoming_msg_number = values[1];
Thread.Sleep(50);
string msg_date_time = values[3];
Thread.Sleep(50);
string msg_text = values[4].Trim();
MessageBox.Show("Number :" + incoming_msg_number + " \r\nDate & Time: " + msg_date_time +
"\r\nMessage :" + msg_text);*
It DIDNT work because there are chances of quaotes within the incoming message
Will regex can do something with this?? if so how??
thanks....
|
|
|
|
|
Aghosh Babu wrote: +CMT:"+658208342",,"09/02/08",16:15:22+50"
Test Message from coder
Are they on two separate lines? In other words, is that an '\n' character I see within the string?
I are troll
|
|
|
|
|
|
+CMT:"+658208342",,"09/02/08",16:15:22+50"
Test "Message" from coder
So, this would fail, since there are quotes on the second line?
Would it help if you split the string based on the NewLine first? Something like this;
string[] Message = s.Split('\n');
This will put the first line in Message[0], and the text-message in Message[1]. You can then safely split your values on the quotes like;
string[] values = Message[0].Split(new char[] { '"' });
HTH
I are troll
|
|
|
|
|
hi thanks, but i cant split with quotes because the incoming SMS may contain quotes too...! any other method other than split??
|
|
|
|
|
The incoming SMS will contain quotes on the second line? If so, there shouldn't be any problem splitting them once you have separated the first and the second line? In other words, Split only on "line 1", without touching line 2:
+CMT:
+658208342
09/02/08
,16:15:22+50
and
Test "Message' from coder
There are lots of methods to manipulate strings, including, but not limited to, regular expressions, the internal string-routines (Substring, IndexOfAny), parsers..
I are troll
|
|
|
|
|
|
I would use a Regular Expression to split the string. Is it always two lines per message? Or sometimes more?
This
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex
(
"(?'A'[^:]*):\"(?'B'[^\"]*)\",,\"(?'C'[^\"]*)\",(?'D'[^\"]*)\"\n(?'E'[^\n]*)\n"
,
System.Text.RegularExpressions.RegexOptions.Compiled |
System.Text.RegularExpressions.RegexOptions.Singleline |
System.Text.RegularExpressions.RegexOptions.CultureInvariant
) ;
is giving me:
A >+CMT<
B >+658208342<
C >09/02/08<
D >16:15:22+50<
E >Test Message from coder<
Did you leave out a quote in your data?
modified on Sunday, February 8, 2009 9:21 AM
|
|
|
|
|
its always 2 lines. is the A,B,C,D,E strings ? can i call these strings later within the method?? Thanks alott. .
|
|
|
|
|
Those are groups, and yes you can access then by name.
If you have a class/struct to hold the data
MyObject objX ;
foreach ( System.Text.RegularExpressions.Match mat in reg.Matches ( text ) )
{
objX = new MyObject
(
mat.Groups [ "A" ].Value
,
mat.Groups [ "B" ].Value
,
mat.Groups [ "C" ].Value
,
mat.Groups [ "D" ].Value
,
mat.Groups [ "E" ].Value
) ;
}
And parse the values in the constructor. That's just one way.
|
|
|
|
|
if u dont mind can u pls explain me how i combine those codes?? where should i add the string?? how i retreive the strings from the regex and display it in a msg box?? thanks a lott... i am a beginer in C#...
|
|
|
|
|
|
You can limit the number of items that the Split returns, so that you get everything after the fifth quotation mark in the sixth item:
string[] values = s.Split(new char[] { '"' }, 6);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
how to receive a frame from serilal port
I want to receive a frame that this frame has CRC start bit ,stop bitplz help to me that how to start this work
|
|
|
|
|
|
Hi, i got some problem here reading my XML using DOM method.
This is my XML file
<invoice>
<number>INV-4773-282009</number>
<date>2/8/2009</date>
<sellerid>2828</sellerid>
<buyerid>2828</buyerid>
<orderid>PO-565029-282009</orderid>
<billingaddress>123 Tampines St 1 #01-55</billingaddress>
<orderitems>
<item>
<productid>P-0003</productid>
<quantity>3</quantity>
<unitprice>42</unitprice>
<description>OCZ Ram</description>
</item>
</orderitems>
</invoice>
This is my code for reading the code
<code>invoiceDoc = new XmlDocument();
invoiceDoc.Load(windir + "\\" + lstFiles.SelectedItem.ToString() + ".xml");
string invNumber = null;
string invDate = null;
string invSellerID = null;
string invBuyerID = null;
string invOrderID = null;
string invBillAddress = null;
string invProductID = null;
string invProductQty = null;
double invUnitPrice = 0.0;
string invProductDesc = null;
XmlNodeList invList = invoiceDoc.GetElementsByTagName("Invoice");
foreach (XmlNode node in invList)
{
if (node.HasChildNodes)
{
XmlElement childNode = (XmlElement)node.FirstChild;
for (int i = 0; i < node.ChildNodes.Count; i++)
{
switch (childNode.Name)
{
case "Number":
invNumber = childNode.InnerText;
break;
case "Date":
invDate = childNode.InnerText;
break;
case "SellerID":
invSellerID = childNode.InnerText;
break;
case "BuyerID":
invBuyerID = childNode.InnerText;
break;
case "OrderID":
invOrderID = childNode.InnerText;
break;
case "BillingAddress":
invBillAddress = childNode.InnerText;
break;
case "ProductID":
invProductID = childNode.InnerText;
break;
default:
break;
}
childNode = (XmlElement)childNode.NextSibling;
}
}
}</code>
<b>Problem : when it comes to productID, it got problem reading. I got nullreferenceexception </b>
<div class="ForumMod">modified on Sunday, February 8, 2009 3:11 AM</div>
|
|
|
|
|
Your XML doesn't show up. Use the "Ignore HTML" option when posting markup code.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Using the XML and code you have provided (except for the casing of node names), I had no exception. It does not access the ProductId node at all and hence i am confused by your problem. What particular line to you get exception on ?
|
|
|
|
|
In the code I'm linking below (feel free to use royalty free by the way), I have an appdomain that is misbehaving.
The classes involved are PluginManager, and PluginFinder. PluginManager creates an AppDomain, using the following code:
public ArrayList LoadPlugins()
{
AppDomainSetup setup = new AppDomainSetup();
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
setup.ApplicationBase = pluginPath;
setup.ApplicationName = "PluginLoader";
setup.ShadowCopyDirectories = pluginPath;
setup.ShadowCopyFiles = "true";
pluginDomain = AppDomain.CreateDomain("Plugins", null, setup);
Type addInManagerType = typeof(PluginFinder);
pluginFinder = (PluginFinder)pluginDomain.CreateInstanceFromAndUnwrap(
addInManagerType.Assembly.Location, addInManagerType.FullName);
ArrayList FoundPlugins = pluginFinder.Search(pluginPath);
...
}
and the finder class has this code:
[Serializable]
internal class PluginFinder
{
private ArrayList FoundPlugins = new ArrayList();
public PluginFinder()
{
}
public ArrayList Search(string path)
{
FoundPlugins.Clear();
try
{
foreach(string file in Directory.GetFiles(path,"*.dll"))
{
TryLoadingPlugin(file);
}
}
catch{}
return FoundPlugins;
}
private void TryLoadingPlugin(string filename)
{
try
{
FileInfo file = new FileInfo(filename);
filename = file.Name.Remove(
file.Name.Length - file.Extension.Length,
file.Extension.Length);
Assembly asm = AppDomain.CurrentDomain.Load(filename);
foreach(Type t in asm.GetTypes())
{
Type baseType = t.BaseType;
bool Complete = false;;
while(!Complete)
{
if (baseType == typeof(BasePlugin))
{
if( !t.IsInterface && !t.IsAbstract)
{
FoundPlugins.Add(t);
Complete = true;
break;
}
}
else if (baseType == typeof(System.Object))
Complete = true;
else
baseType = baseType.BaseType;
}
}
}
catch(Exception e){throw e;}
}
}
The problem is, when the AppDomain calls Load, it looks in the wrong directory! pluginPath of the Manager is set when Instantiating it, using "Plugins\", but Debugging AppDomain.CurrentDomain.BaseDirectory within the Finder returns different than pluginDomain.BaseDirectory! Basically, the Search method of the finder is finding the files, but the TryLoadingPlugin throws an exception due to the AppDomain problem. Any ideas? I have the TestPlugins Project compile to the Apps \Debug\Plugins directory, which is where the Manager is set to look, but I end up needing to copy the Plugins to the \Debug\ directory if I want them to load. :/
Source Code: GMail Notifier[^]
|
|
|
|
|
try
foreach(string file in Directory.GetFiles(path,"Plugins\*.dll"))
The working directory of the executable equals the directory where that executable is launched from. I guess that the plugins are loaded as a part of that executable and therefore share the same working-directory.
Hope this helps
I are troll
|
|
|
|
|
Unfortunately that won't work, if you follow the code posted closely. "Plugins\" is given to the path, and "*.dll" the mask of the file. using your method, and without trying it, I'd guess it'd look for Plugins\Plugins\*.dll and crap out because the path doesn't exist. Also, you forgot a "\", should be "Plugins\\*.dll" or @"Plugins\*.dll", but that's just me being a perfectionist.
I figured out what the problem was, anyway, to a point. I forgot to inherit MarshalByRefObject, but adding that has caused other problems. Namely when code returns to the Manager from the Finder, I get a file not found exception when copying the Finder's array to the array in the Manager. Note the Bold line:
AppDomain domain = AppDomain.CreateDomain("PluginLoadingDomain", null, setup);
Type finderType = typeof(PluginFinder);
PluginFinder finder = (PluginFinder)domain.CreateInstanceFromAndUnwrap(
finderType.Assembly.Location, finderType.FullName);
FoundPlugins = finder.Search(pluginPath);
AppDomain.Unload(domain);
It seems that my main appdomain wants to load the files, based off the fusion binding logs (Mentions that cant load file under \Debug\, instead of \Debug\Plugins\), so any help there would be appreciated.
|
|
|
|
|
Out of my league, obviously
(path + "\\Plugins\\", "*.dll")
iAmEntity wrote: @"Plugins\*.dll", but that's just me being a perfectionist
The compiler interprets them very differently, so it's not an insignificant detail. I got them mixed up regularly, until I changed the syntax-coloring of the C#-verbatim string. In my defense, CP doesn't have syntax highlighting (yet)
I are troll
|
|
|
|
|