|
|
Yes, as when using add-ins. I've done a few.
1 + 2) Those concepts don't apply to runtime, only to development and compile time.
Your app can browse the directory for DLLs, load the assemblies they contain, and it can then instantiate and use the classes therein.
But it has to know what sorts of things it can do with the classes.
For doing add-ins, I define an Interface (or abstract class) that the app knows about.
After the app loads the assembly it browses the classes contained and instantiates any it finds that implement the Interface.
See System.Reflection.Assembly
|
|
|
|
|
Hi,
I spent a bit of time yesterday debugging a previously working app and eventually traced my problem down to the default handling of command line arguments.
So, assume a console app using the standard Main method of
static int Main(string[] args).
If I format a command line argument as say
"\DataFiles"
then I get the expected args[0] of \DataFiles which has had the quotation marks stripped off.
If I pass \ then I get args[0] of \ , again as expected.
However if my command line is quoted and has a final backslash then it all goes a bit wrong.
So "\DataFiles\" turns up in args[0] as \DataFiles" from which it appears that the \ is being interpreted as an escape character.
Just for a bit of fun I passed in the command line argument "\"\"" to confirm the hypothesis and got "" in args[0] as predicted.
I know there are plenty of command line parser classes which will do the job properly but can anyone explain the rules for the inbuilt parsing as I can't find any reference to the rather odd action that I have found.
Alan.
|
|
|
|
|
Alan N wrote: "\DataFiles\" turns up in args[0] as \DataFiles"
Hi,
\" is the way to include a double quote inside a string literal in C/C++/Jave/C#
If you intend for "\DataFiles\" to be a C# literal, then it fails twice:
the \D is an invalid escape sequence,
and the string literal is not closed on the line, since the \" is a valid escape sequence which
translates to a double quote (and hence does not terminate the literal)
BTW: don't get fooled by some debugger output in Visual Studio, they are known to mangle the quotes
a bit.
Hope this helps.
|
|
|
|
|
Hi Luc,
Thanks for the response, however I've not sure you understood what I
was getting at.
You are absolutely correct about escape sequences, but surely this
behaviour only applies to literals defined within code, i.e. those that
will be parsed by the compiler. I was referring to quoted strings
entered on the command line and parsed into the args array by the C#
startup routines. Here the \ acts as an escape specifically for the
double quote character. It is not a general escape as, for example, I
do not have to write \\DataFiles\\file1.txt to get \DataFiles\file1.txt
into the args array.
As I was writing this I realised that the startup routine that does the
parsing for C# will be the Environment.GetCommandLineArgs method and the
online help for that does at least document the behaviour.
and I quote...
If a double quotation mark follows two or an even number of
backslashes, each proceeding backslash pair is replaced with one
backslash and the double quotation mark is removed. If a double quotation
mark follows an odd number of backslashes, including just one, each
preceding pair is replaced with one backslash and the remaining backslash
is removed; however, in this case the double quotation mark is not
removed.
A bit more research on this odd behaviour has revealed that it is present
in the win32 function CommandLineToArgvW. It is a pity that Microsoft
didn't choose to implement something a little more logical in the
Framework library.
References
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx[^]
http://msdn.microsoft.com/en-us/library/bb776391(VS.85).aspx[^]
http://weblogs.asp.net/jgalloway/archive/2006/09/13/Command-Line-Confusion.aspx[^]
Alan.
|
|
|
|
|
Hi Alan,
I wasn't sure you meant C/C# literals or not, that's why I started with "If...".
I now understand the documentation is adequate, it describes the behavior, which does not
really correspond what you, and I for that matter, would hope to get.
I do recall a strange Dr.GUI article that stated something like: in a path where more than
one subfolder name contains one or more spaces, it is not sufficient to enclose everything with
double quotes, instead each spaced subfolder needs its own pair of double quotes. Which I now
understand is one valid way of coping with the specs.
And which
1) I did not care to test,
2) did not like at all,
and 3) made me put a lot of files not in "Program Files" (I use "PF"), and certainly not
in "Documents and Settings" (not relevant any more in Vista).
Thanks for the clarification on CommandLine stuff!
|
|
|
|
|
I need to build a program that can take any number of letters and find all the legitimate words in that list of words.
I need an algorith to find words from the list of letters, and a way of comparing that to a dictionary or something.
Where do I start? I don't want an anagram program, since I want to find all words, regardless of length.
DAM.
|
|
|
|
|
What do you have done so far?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Is it a word or letters search? i builded in sql some store procedures to acomplish that. Is it a database + windows project?
|
|
|
|
|
I haven't started it yet. I want to do it in Visual Studio 2008, with C#. I'm not sure if I really want to do a database, unless there's an easy way to import a huge dictionary or something. I don't want to be responsible for building the dictionary, there's gotta be one out there somewhere.
Here is a more detailed breakdown of what I think I need:
1. Take input of letters ( say, up to 16 ).
2. Allow user to select the minimu letter-length of the resultant words ( i.e. discard all words that are less than that number of letters ).
3. Generate a list of all possible words that can be spelled from the list of letters provided, with each letter being used once and only once. Now, if a letter appears more than once in the list, then that letter can appear exactly that number of times in a resultant word.
4. Allow the list to be ordered any way the user wants it to be.
I'm sure there's more things I'd like to add eventually, but I'll start here for now.
DAM.
|
|
|
|
|
Hi,
I´am not an advanced programmer.
I think you should start doing that and ask here then.
I code searches in sql server and trigger it in c#, but if you have some kind of users that add/edit "words" to your dictionary it looks like a web application and you have to use sql databases! where would you store the data? Ask other opinions
Good Luck!
|
|
|
|
|
Hi All,
I've beenconverting some java classes to C# and am getting buffeted by headwinds with the network code conversion. Here is a block of code that has me at a loss for now:
try {
Enumeration<networkinterface>; interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
Enumeration<inetaddress> addresses = interfaces.nextElement().getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
if (!addr.isLoopbackAddress()) {
address = addr.getAddress();
}
}
}
}</inetaddress></networkinterface>
I've interpreted the statement:
Enumeration<NetworkInterface>; interfaces = NetworkInterface.getNetworkInterfaces();
as:
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
...which return a list of network interfaces on the host. However, the statement:
Enumeration<InetAddress> addresses = interfaces.nextElement().getInetAddresses();
...is giving me more trouble. I know the type that I want to create (IPHostEntry - I believe that's correct) but I can see no way to identify the IP Addresses associated with a given network interface (when the host is multi-homed). The C# classes that I have seen all seem to generically assume that the host has 1 interface which may have more than 1 IP Address.
So my questions is, in a nutshell, if a host has multiple network interfaces how does one identify the ip addresses associated with each interface?
All suggestions warmly welcomed...
Regards,
Dave
|
|
|
|
|
DwR wrote: So my questions is, in a nutshell, if a host has multiple network interfaces how does one identify the ip addresses associated with each interface?
Well your question does not seem to reflect the block of Java you posted but the NetworkInterface [^]and IPInterfaceProperties [^] examples in their documentation seem to answer your question.
led mike
|
|
|
|
|
As I'm not a java developer what is your interpretation of what that block of code is doing? That's one the problems I have. I'm trying to convert the code without being able to interactively debug it to see what it does.
Regards,
Dave
|
|
|
|
|
DwR wrote: what is your interpretation of what that block of code is doing?
It is looping through all of the network adapters and all of the addresses in each adapter and filtering out the loopback address/adapter. Finally the last ( well each one in turn without any exiting of the loops therefore the last one) adapter.address in the enumerations that is NOT the loopback adapter is assigned to the variable address , which is not declared in the code you posted so I have no idea what it is.
address = addr.getAddress();
led mike
|
|
|
|
|
|
Hi,
I need to pull some table from SQL server; some are for read-only purposes while others will be both for reading and writing. I need to put these tables on laptops which do not have SQL server installed. I was thinking of storing them in XML files. My questions are:
1. What is the best way to store the tables on laptops for application to use? These tables will need to be synchronized with the main server once connectivity is available.
2. I know for pocket pcs there is pull and push mechanism available. What kind of mechanism should I use in my case?
3. What precautions should I take or things I should be aware of for such a project?
Thanks in advance.
|
|
|
|
|
Hi,
You don´t need to install sqlserver in all laptops, just install it in the Master/Server computer.
To pull data from sqlserver tables i think you already created some store procedures (don´t forget to make your threads safe).
On the Client side (laptops) you install the application you designed that only has the acess to edit & read what is in the Server´s database, by triggering the store procedures you created.
(In c# Forms, use the datagridview object to display sql data).
Server -> database
Clients -> application to acess/display database
About your (1st point)
It is good pratice to have only 1 database(meaning Server) in the "web/net" you create.
You don´t store data on the Laptops because you will get 12 diferent databases (both Server and Clients) named the same with diferent data/update.
If you can´t connect to the Server, bad luck try later.
I hope a helped you here. Ask someone else for more advanced help. Good luck
|
|
|
|
|
Thanks for the help but not a good suggestion. Often times we have no connection but that does not mean we can not work.
I will pull the data and store them in xml files and once connection is available the app will synchronize with central db.
I have the stored procedures and you are right about that.
Thanks
|
|
|
|
|
Hello,
I am new to .net n working with Framework 3.5
Currently working on Application developed in Borland Delphi.
We have 2 exe's named as DBPro.exe and Data.exe
I am rewriting Data.exe which deal with Data Interaction with SQL Server.
Now the project work like, We have button in DBPro.exe which Opens up Data.exe n while doing this it Passes the Message to it using Post Message. I dont have code for DBPro.exe
After All work wen we close Data.Exe it is suppose to PostBack message to Calling Exe i.e. DBPro.exe which will reinitialize it.
I found line PostMessage(HWND_BROADCAST, dbmesg, 0, 0); in Data.exe, in the Form End section which is suppose to Post Back the Message. Now I want to do the same with my new Data.exe. So far I found I can use some invoke method but have no idea how to use it.
I'll appriciate any pointers on this issue.
Thanks.
Some declarations look like this..
PostMessage(HWND_BROADCAST, dbmesg, 0, 0);
strpcopy(mstr, 'WM_DBMESG');
dbmesg:=RegisterWindowMessage (mstr);
I am not able to found any declaration for HWND_BROADCAST
Niks
|
|
|
|
|
I posted the Problem.. n found the answer for it.. M calling PostMessage on Button Click!!
private void btnClose_Click(object sender, EventArgs e)
{
const int dbmesg=49706;
const int HWND_BROADCAST=65535;
Win32.PostMessage(HWND_BROADCAST,dbmesg, 0, 0);
this.Close();
}
public class Win32
{
[DllImport("user32", EntryPoint = "PostMessage")]
public static extern int PostMessage(int hwnd, int wMsg, int wParam, int lParam);
}
This will Close the Data.Exe and Broadcast Message. I Defined the same constant I found in Old code, even when I dont really know what they really mean..
But this code is working for me..
To Import Win32.dll need to add using System.Runtime.InteropServices; namespace!!
Guys.. any one know how exactly this work.. to give more understanding..!!
Thanks
Niks
|
|
|
|
|
I am designing a sci-fi game and need to create a "map" of the galaxy (a 8x8 grid) that contains space objects (stars, planets, spaceships, etc) some of these objects contain no more than a name property, but some like the spaceships are more complex having methods as well as properties.
What I am confused about is that a collection holds a list of a-like objects, so it could hold a list of planets or stars but not both.
So, how can I create a Galaxy collection containing all the different types of space objects?
I am not looking for code just some advice on how to implement.
Thanks,
Lee.
|
|
|
|
|
The most elegant solution is to create an interface, like IGalaxyObject, and make all you classes implementing it.
It could look like the following:
public interface IGalaxyObject
{
void DrawYourselfOnTheGrid(Rectangle coords);
}
public class Star : IGalaxyObject
{
public void DrawYourselfOnTheGrid(Rectangle coords)
{
}
}
ICollection<IGalaxyObject> galObjsColl = GetCollection();
foreach (IGalaxyObject galObj in galObjsColl)
{
galObj.DrawYourselfOnTheGrid(someCoords);
}
|
|
|
|
|
Sounds suspiciously like the Summer Code Competition[^]. Just remember, if you receive any help from CP (articles or forum posts):You must specify any resources (code, concepts, research etc.) used in creating your article that were not originally produced by you.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
I was thinking of doing something for this - but having a black hole at the centre of the galaxy and using gravity sling shots to gain higher warp speeds... but then I realized how sad I was!
Dave
|
|
|
|