|
Unfortunately it is for evaluating an expression tree so we don't know until we are running what an expression will evaluate to.
I have found that the compiuler turns operator + to a method op_Addition so i guess I need to do a GetMethod("op_Addition")?
|
|
|
|
|
I can't answer that, I don't know enough of your problem domain.
I would refrain from relying on undocumented but observed compiler behavior whenever possible.
I do know when I create an interpreter/parser-like system, I use small data structures to describe what I am dealing with, i.e. something holding name, value, type, etc.
Then when some operator needs executed, its code can check its operands' types and act accordingly.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Nope, that would require an interface. MS could probably write generic interfaces to do that, but I don't think they'd apply them to the built-in types retroactively.
P.S. You might want to see what I did here[^].
|
|
|
|
|
Hi,
I have a problem to get single numeric values from an Excel worksheet (that I need to process as I receive it). I use the Microsoft Excel 9.0 Library because I need to process EXcel 2000/2003 files.
This is the range:
Excel.Range CellRange = (Excel.Range) WS.Cells[RowNum, ColNum];
I use this statement to check format and cell.
MessageBox.Show(CellRange.NumberFormat.ToString() + "\n" + RowNum.ToString() + "\n" + ColNum.ToString());
Only in case of format 0.0 I can get a value (e.g. 234.9) like this:
Result = Convert.ToDouble(CellRange.Value);
MessageBox.Show(Result.ToString());
But the format can also be General with values e.g. 234.9 (with point), 234,9 (with comma) or 2349 (without separator).
It must be simple, but I can't find the solution.
Who can help me?
Thanks,
Gijs
|
|
|
|
|
Convert.ToDouble("34.13", CultureInfo.InvariantCulture);
There's also a CurrentCulture
I are Troll
|
|
|
|
|
Yes, the CultureInfo helps in certain cases.
But I don't manage to get a value (string or numeric) from a cell with type 'General'.
The single cell range 'Value' is null, although the Excel cell contains a few characters.
Thanks,
Gijs
|
|
|
|
|
Hello,
I am writing a server/client application and I have encountered a weird problem. The server handles several TCP connections and sometimes sends messages to the clients. Now, if I send these messages too "fast" they are not sent at all. However, if a Thread.Sleep(1000); command is introduced before sending a message everything works fine (except it is very slow). Maybe it is relevant that the Send() method is called by different threads , triggered by events (locking the communication object does not help). Here is the code:
public void Send(int id, string message)
{
StreamWriter writer = new StreamWriter(connections_[id].GetStream());
writer.WriteLine(message);
writer.Flush();
}
|
|
|
|
|
What is your receive code, perhaps it is incorrect.
Personally I always use the sockets code instead of writing to the streams directly and it always seems to work.
|
|
|
|
|
This is my receive code. It works fine until the calls are getting crowded:
public string Receive(int id)
{
StreamReader reader = new StreamReader(connections_[id].GetStream());
string result = reader.ReadLine();
return ProcessQuery(result);
}
|
|
|
|
|
I see your problem. Eliminate your List of connections from both the client and the server, pass the id in the stream, and use one connection for all of the communications. It will work just fine.
ie:
RecieveThread(){
BinaryReader br = new BinaryReader(stream);
while(go){
int messageId = br .ReadInt32();
sring message = br .ReadString();
}
}
This is untested psuedo code just to give you a starting point.
|
|
|
|
|
|
Hi,
IMO Flush() is the wrong method to call. You need Close() and Dispose(), not Flush().
A "using" statement would fit well.
And Ennis is right, why not use Socket class?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I cannot close my conenction because I will need it later...
Perhaps I try the Socket class.
|
|
|
|
|
I didn't say anything about a connection, I was yalking about your writer, the one you create a new of every time, and never Close nor Dispose. And don't tell me you have shown fake code, I hate that, one should show real code to get real solutions.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Would someone point me to library were I could find a solution to cloning 'execlp' or 'fork' in Windows?
I need WinWord to look like it's being executed from the correct path: C:\Program Files\Microsoft Office\Office12\WinWord.exe when in reality it's being launch from a Java app using the path C:\Program Files\Microsoft Office\Office11\WinWord.exe. A program (Java) from the Internet (so it only knows the configuration it has stored) launches 'C:\Program Files\Microsoft Office\Office11\Winword.exe' and sends it a macro to build a form on the client. Somehow I need to catch it and have it open winword from the correct path. Changing the path in the Java app isn't an option (unless someone is clever enough to trick it to the correct winword). I'm using visual studio 2008 Express C# but can download anything for free.
How do I do this?? Where do I start? I do SQL for a living not C#.
I've tried hardlinks 'fsutil hardlink create' but winword sees the Office11 in the path and launches Office Repair. I've tried copying the files in to an Office11 folder that I created which caused Office to launch repair. noticing a theme
I was thinking something like 'fork' or 'execlp' where Office11\winword(my app) launches Office12\winword and the ?data pipe? is inherited or parameters are passed to this real, M$, Office12\winword and runs the macro in M$ Word.
Thanks in advance for your help!
Alonzo
modified on Monday, August 10, 2009 8:44 AM
|
|
|
|
|
My ultimate goal is to place shortcuts onto the desktop and startmenu of the files my application is copying to the workstation.
I found some code that allows me to create a shortcut file but I can not get the reference to work because I can not find the reference for IWshRuntimeLibrary in VS 2008 C#.
Does anyone have any suggestions on code I could use or reference to understand a better way of creating these shortcuts.
The Code below allows me to add a shortcut using :
Link.Update(Environment.SpecialFolder.DesktopDirectory, FileDestination, "Shell Link", true);
Here is the code that I found.
public class Link
{
/// <summary>
/// Check to see if a shortcut exists in a given directory with a specified file name
/// </summary>
/// <param name="DirectoryPath">The directory in which to look</param>
/// <param name="FullPathName">The name of the shortcut (without the .lnk extension) or the full path to a file of the same name</param>
/// <returns>Returns true if the link exists</returns>
public static bool Exists(string DirectoryPath, string LinkPathName)
{
// Get some file and directory information
DirectoryInfo SpecialDir=new DirectoryInfo(DirectoryPath);
// First get the filename for the original file and create a new file
// name for a link in the Startup directory
//
FileInfo originalfile = new FileInfo(LinkPathName);
string NewFileName = SpecialDir.FullName+"\\"+originalfile.Name+".lnk";
FileInfo linkfile = new FileInfo(NewFileName);
return linkfile.Exists;
}
//Check to see if a shell link exists to the given path in the specified special folder
// return true if it exists
public static bool Exists(Environment.SpecialFolder folder, string LinkPathName)
{
return Link.Exists(Environment.GetFolderPath(folder), LinkPathName);
}
/// <summary>
/// Update the specified folder by creating or deleting a Shell Link if necessary
/// </summary>
/// <param name="folder">A SpecialFolder in which the link will reside</param>
/// <param name="TargetPathName">The path name of the target file for the link</param>
/// <param name="LinkPathName">The file name for the link itself or, if a path name the directory information will be ignored.</param>
/// <param name="Create">If true, create the link, otherwise delete it</param>
public static void Update(Environment.SpecialFolder folder, string TargetPathName, string LinkPathName, bool install)
{
// Get some file and directory information
Link.Update(Environment.GetFolderPath(folder), TargetPathName, LinkPathName, install);
}
// boolean variable "install" determines whether the link should be there or not.
// Update the folder by creating or deleting the link as required.
/// <summary>
/// Update the specified folder by creating or deleting a Shell Link if necessary
/// </summary>
/// <param name="DirectoryPath">The full path of the directory in which the link will reside</param>
/// <param name="TargetPathName">The path name of the target file for the link</param>
/// <param name="LinkPathName">The file name for the link itself or, if a path name the directory information will be ignored.</param>
/// <param name="Create">If true, create the link, otherwise delete it</param>
public static void Update(string DirectoryPath, string TargetPathName, string LinkPathName, bool Create)
{
// Get some file and directory information
DirectoryInfo SpecialDir=new DirectoryInfo(DirectoryPath);
// First get the filename for the original file and create a new file
// name for a link in the Startup directory
//
FileInfo OriginalFile = new FileInfo(LinkPathName);
string NewFileName = SpecialDir.FullName+"\\"+OriginalFile.Name+".lnk";
FileInfo LinkFile = new FileInfo(NewFileName);
if(Create) // If the link doesn't exist, create it
{
if(LinkFile.Exists)return; // We're all done if it already exists
//Place a shortcut to the file in the special folder
try
{
// Create a shortcut in the special folder for the file
// Making use of the Windows Scripting Host
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LinkFile.FullName);
link.TargetPath=TargetPathName;
link.Save();
}
catch
{
MessageBox.Show("Unable to create link in special directory: "+NewFileName,
"Shell Link Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
else // otherwise delete it from the startup directory
{
if(!LinkFile.Exists)return; // It doesn't exist so we are done!
try
{
LinkFile.Delete();
}
catch
{
MessageBox.Show("Error deleting link in special directory: "+NewFileName,
"Shell Link Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
}
|
|
|
|
|
In VS2005 (probably the same in 2008) to get the IWshRuntimeLibrary in your project you need to add a reference to the "Windows Script Host Object Model" to your project. It's under the COM tab in the "Add A Reference" dialog.
|
|
|
|
|
Dear All, c# and SQL Guys.
we are working in Distributed envoirnment, we have got 34 remote office and 1 HQ,
each remote office runs access application with c# as frondend and HQ runs SQL 2005.
well, i have created a service in remotes office which gets any newly record from .mdb file and then creates an xml file of that, then sends this xml to remote FTP.
from HQ another service runs which gets those xml files from FTP and then manipulates those statements against our HQ database.
we have made replication between our HQ and WEb SERVER which both runs SQL 2005. Replication works perfect.
creating xml from remote office are perfect, downloading and executing them against HQ Database is again perfect.
i have a question
1. I want to get newly records from HQ and WEB SERVER and then these records should be in remote office "what method u guys recommend?"
we have also web application which is connected to WEB SERVER
I would really ur ideas and also their benefits with drawback
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
DateTime stamp for record update or a GUID. If you use a date time stamp all of your offices will need to use GMT internally for date checks, if you use the GUID, inadvertent overwrites can occur if you go in the wrong direction.
|
|
|
|
|
well, i think u r not more clear. can u please clearfy your idea.
well, i am asking about how to get updates from HQ and WEB SERVER to remote office.
adding GUID or timestamp column to tables, well, then what method use to get these updates from remote offices.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Can't be bothered. Besides the rules of the forums don't allow me to say what I want to.
|
|
|
|
|
I am really sorry, my question was only to understand ur idea.
so kindly i asked u to make your idea alittle bit clear.
once again if some thing was wrong i am really sorry!!!
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
There is no real answer I can give other than suggesting you use a DateTime stamp or a GUID without actually writing code for you. There are literally hundreds of ways to sync up remote machines with a central server. The best method is a direct result of looking at your current implementation and seeing what works the most accurately under the constraints that your system has in place. What methods have you tried that have failed? Or have you not written any sample code yet?
|
|
|
|
|
well, i haved sued this method.
i have created triggers in some tables in WEB SERVER which i need the data from.
when certain data changes so those triggers are fired and certain fields are changed and at all these tables has one field which shows certains records are udpated.
from remote office iam looking for those field which show they are updated, then i am executing CLR Query which create xml of those updates and then i am downloading thoese updates to remote office.
but the only thing which i want is how i should the WEB SERVER that these are downloaded by another PMU.
in case if the xml file creation is succesfull, and no flag has occured to WEB SERVER then what i should do to not download a file twice,
i dont want to delete files from ftp, bz they are sometimes used as backup.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hello All ,
i know that DLLImport is used to call some unmanaged Code . Like some third party dll is there and we want to make use of that .
But my question is like i have created one class library using .net only . So when i build that i had DLL too of that . this is managed code .
Now i have placed this dll in GAC.
i want to make use of this DLL in my application by using DLL Import. when i tried it is throwing an exception like DLL not found .
So my question cant we call managed dll using DLLImport ? i know i can add that dll as a refernce and can use it but i dont want that . So it possible with DLLImport or it is only for unmangedDLL.
2. if suppose i am calling an unmanged DLL i.e third pary compnent ... how CLR will locate its address using DLL Import
Sorry for trouble .. But my mind is messed with this.
|
|
|
|
|