|
I think the problem is because it'n not adding me something into the list. I dont know exactly, but I have a kind of error like this :
"Index out of range. Must be non-negative and less than the size of collection ".
|
|
|
|
|
That means that you're using an array and not a list class. And you're trying to add past the size of the array. Like the error message says.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dear all,
This morning I encountered a problem I have never had before. I created a project a few weeks back with the namespace CookBook. It compiles and runs just fine. This morning I opened another project with a different namespace. Compiled it, and this project runs fine too. My sick mind thought it would be nice to combine the two projects, however ... two different namespaces. So I imported the second project in the solution of my first project and changed the namespace of the second project to match the first. After changing the namespace, the entire solution compiles fine. I then wanted to refer to a class inside a form in the second project. Since both projects have the same namespace, you would expect the classes in the second form ( with the changed namespace ) to globally show up as CookBook.[class] .
However , this is not the case. It simply tells me : No reference , etc during compilation. Can anyone explain to me , what I am doing wrong. I would like the entire second project to be a part of the first project so I can call classes from inside both forms. The projects are pretty large, so importing the forms ( add existing Item ) into the projects is not an option. Do I have to rebuild the class library somehow ( and if so , how do I do that ? ). I'm using VS2005.
I highly appreciate any input. Kind regards, and many thanks upfront !
Cheers,
|
|
|
|
|
i think you have two projects with the same namespace in your solution.
in VS2003, (i don't have VS2005 this would create two separate .dll library files containing only the functions defined in their respective project files.
so, if you want to use the function from the second project, you will have to import that file and not the first one.
If you want ALL in one file then just combine the two projects together which when compiled will result in a single library file. there may be other methods but i don't know them
i don't know how it works in VS2005, i'm sorry
regards
|
|
|
|
|
Having two projects inside the same solution does not make them know anything about each other. In order to use the classes, interfaces, etc. of one project, it has to be referenced by the project that wants to use the stuff. Now that the second project knows about the first one, you can access all things declared public in the first project independent of their namespace.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you for your kind and swift reply. I was under the impression that importing a project into a solution automatically meant that they know about each other. Obviously not. However, how can I reference a complete project ( or the namespace for that matter ) into a project.
using CookBook; at the top of the form is still generating the same error during compilation and so is using the complete name ( namespace.class.method ).
|
|
|
|
|
Inside the project explorer right-click on "References" and select the "Add reference..." option. In the dialog that opens that should be a "projects" tab.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Try the following way
Rightclick the project->add reference->Project->Select the project
Regards
R.Arockiapathinathan
|
|
|
|
|
Thank you once again for your reply. But adding project A to B , and B to A would create a circular dependency right ?
|
|
|
|
|
Yah, its right.
If this is the case, you have to restructure you projects and create one more project and push the common things into that project and refer that into both projects.
Regards
R.Arockiapathinathan
|
|
|
|
|
Can someone help me telling me how can I convert a element of a list to int?
|
|
|
|
|
You could call Convert.ToInt32(listArray[0].ToString()); . Alternatively, if you're using .NET 2, I would recommend just creating the List as List<int> list = new List<int>();
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: call Convert.ToInt32(listArray[0].ToString());
Is there any reason why you are calling ToString() ? Convert works on object too... Only meaningful thing I can think of is to provide IFormatProvider , but then again there is Convert.ToInt32 (Object, IFormatProvider) overload.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
dnh wrote: Is there any reason why you are calling ToString()
Yup - typing in away from a dev box and doing it from memory - I don't tend to use the .NET 1 list anymore.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
If the list is of int s to begin with, only a cast required.
|
|
|
|
|
Hi,
I'm trying to find all classes that implement a specific abstract base class inside an Assembly, so far I have got the following...
Assembly assm = Assembly.GetExecutingAssembly();<br />
<br />
foreach (Type type in assm.GetTypes())<br />
{<br />
if (type.IsSubclassOf(typeof(MyAbstractClass)))<br />
{<br />
Response.Write(type.ToString() + "<br />");<br />
}<br />
}
...and this seems to work OK. However, my assembly is already fairly large and may grow, and as far as I can tell this code iterates through all types in the assembly, which I feel is inefficient.
I know all my derived classes will sit inside the same namespace, so was wondering if there's a way to iterate through all types inside a particular namespace only, instead of the entire assembly?
Cheers!
|
|
|
|
|
OK, I've had enough and need to ask. I'm looking at some Interop work carried out in .Net 2.
Essentially we have a VB6 application and associated classes, some of which provide Interfaces. As part of a recent project a .Net 2.0 'plug-in' has been developed, which implements a particular Interface from the aforementioned VB6 project. This 'plug-in' is then exposed to com and made accessible back to the aforementioned VB6 Application via Interop, (I know - it's horrible).
The items from the .Net 2.0 plug-in which implement the interfaces are themselves in turn implemented by a menu item in the VB6 application. They're early bound and a specific method is called at start up and at shut down. Event logging in the .Net 2.0 application suggests all of the elements of the call at start up and shut down are run to completion. When the VB6 application is started with the menu item implementing the plug-in attached, a 'Memory could not be "read"' application error is against the VB6 app is caught by the OS, (Windows XP), after application shut down whether you do or do not click the menu item. When the VB6 application is run in debug, the error is thrown when Visual Studio is exited.
Does anyone have any idea what could be causing this?
Cheers,
NB: If the above is confusing or unclear, I can try to clarify
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
I have populated a dataset with one table.
The data in the table looks as follows:
Index1Name Index2Name City Value
Indexk Indexk city1 2
Indexk Indexk city1 3
Indexk Indexd city1 2
Indexk Indexy city1 1
Indexy Indexk city1 1
Indexx Indexk city1
Indext Indexq city1 5
Indexs Indexs city1 6
Now I would like to have an array which gets populated from the distinct values in columns of Index1Name and Index2Name
So the array should contain something like:
Indexd Indexk Indexy Indexx Indext Indexs Indexq
Thanks
|
|
|
|
|
You can loop thru and write your own logic to fill in the array(s) you like.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi,
Im using C#.Net 2003,im using windows 2000 operating system.. i retrieved all the available windows user by using the following code and listed in the listbox..
private void button2_Click(object sender, System.EventArgs e)
{
using(DirectoryEntry root = new DirectoryEntry("WinNT://node-10"))
{
foreach (DirectoryEntry child in root.Children)
{
if (child.SchemaClassName == "User")
{
listBox1.Items.Add(child.Name);
}
}
}
}
Actually i want to check is it the right user or not from the C#.Net by programmatically..
in textbox1 im entering the username and
in textbox2 im entering the password
on clicking the ok button it should check whether the entered username and password are the right one or not,if it is the right one, then in messagebox("Valid user") else in messagebox("Invaliduser").and also mention if need to refer any namespaces over here...How should i achieve this one...plz help me..its urgent...
rgrds
Kanna..
|
|
|
|
|
Dotnetkanna wrote: plz help me..its urgent...
I wish I had a dollar for every CP post that ends with that.
Why do you want to do this ? I'd be sad if it were possible to write an app that tells a user on a PC the username and password of all users on that machine. But, why would you require someone to log on using creditials they have already logged on with ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: But, why would you require someone to log on using creditials they have already logged on with ?
I was just thinking that.
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|