|
Your code as it is will compile. But in the OP's case, he has no type there yet, so it wont work (you cant just make one there!).
So to wrap it up:
- he loads an assembly
- he gets a type (one that is not known when he compiled the code)
- make a generic List of the runtime type via Type.MakeGenericType, as the type is not known at compile time
|
|
|
|
|
leppie wrote: But in the OP's case, he has no type there yet
Which is why I mentioned that additional constraints would be needed. For instance, he could use IList as a constraint to identify that the item is a list of type T.
|
|
|
|
|
The OP is trying to instantiate a generic class, with only the Type instance for the actual type available. In your example, you were able to pass MyClass as a type parameter, the OP has only typeof(MyClass), which he got through reflection.
|
|
|
|
|
Well spotted - I missed that. That'll teach me not to skim read the question.
|
|
|
|
|
Look at Type.MakeGenericType().
You will have to do something like:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
Type ltype = typeof(List<> ).MakeGenericType(type);
IList list = Activator.CreateInstance(ltype) as IList;
Note: The bolded types are not generic types, you can use a generic IList if the type or its parent or interfaces are known at compile time.
[update] Or simply use an ArrayList or List<object> [update]
modified on Thursday, June 19, 2008 1:24 PM
|
|
|
|
|
Hello,
I have a lot of asp pages and i have to change to search in this pages to know where a specified method is called.
I have tried more program but no one work.
Do someone know the name of a powerfull software that can a good search.
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Windows explorer search (using A word or phrase in file) is good, as is Visual Studio.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I'm using HttpWebRequest & HttpWebResponse classes in my application. I have SSH proxy on my computer which IE or FIREFOX use it to connect to internet. How can I make my application use the same proxy or use the setting in IE? The WebProxy class didn't help me.
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
WebProxy.GetDefaultProxy() although deprecated will return the proxy of IE.
|
|
|
|
|
Hi to all!! Can any body help me abt asterisk ,how to generate call in asteriskwin32 to a local phone in windows xp. How to write call files and entension.conf.
|
|
|
|
|
CP has an article on Asterisk. Search for it.
|
|
|
|
|
Hi,
I want to copy files from one network path to another network path through windows serivce.
I am impersonating the user but it works only for one network path at a time. If I try to impersonate another user the first one becomes invalid.
Is there a way through which we can impersonate two users simulateneously.
I know other way is that I copy file from source network path to local system and then copy it from local system to destination network path i.e impersonating one user at a time but there are other things in my code which will make this too complicated.
I would really appreciate if anybody can help me on this.
Regards,
Rahul Rastogi
|
|
|
|
|
rahulrmetadesi wrote: Is there a way through which we can impersonate two users simulateneously.
I doubt that.
I suggest you tell your 'lazy' admin to create a domain account for you and provide the necessary permissions. It's not your job as a developer to do this.
|
|
|
|
|
Hi Guys,
I solved the problem of the MDI child not maximising, many thanx to all the replies.
What happens now is when an item is selected in a listbox on a dialog form [the dialog is called using ShowDialog() ], it should open another form in an MDI as a child. unfortunately this new child is under the other children.
Question: How do i make it the topmost child to be displayed.
thanx 4 ur anticipated response.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Call the Activate method on the new form.
|
|
|
|
|
i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum
string name;
decimal price, due;
int count;
name = txtSelectedItem.Text;
price =decimal.Parse( lblPrice.Text);
count =int.Parse( txtUnitOrder.Text);
due = decimal.Parse(lblDue.Text);
DGSelectedItems.Rows.Add( name,price,count,due);
decimal sum = due++;
txtSum.Text = sum.ToString();
the value didn`t incremented but replaced
regards in advance
|
|
|
|
|
Mr.Kode wrote: decimal sum = due++;
due is incremented after is is assigned to sum... you want...
decimal sum = ++due;
That should fix it.
Matthew Butler
|
|
|
|
|
Hi All,
I have made one window service in which i have included some COM components like Microsoft.Internet Control.
In a seperate Window application my code is working properly but when i integrate that code in my window service in gives me COMException like
System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error: 8007000e.
Is there any solution for this kind of error????
Thanks in advance
Himal Rupera.
|
|
|
|
|
So have you told the service that it may interact with the desktop?
|
|
|
|
|
yes i have told to service that it can interact with desktop
|
|
|
|
|
Sorry cant help more. Maybe the ApartmentState? Google reveals over 2000 matches with that error code.
|
|
|
|
|
i have a question about the application i have made that is on some pcs the numeric values decimal separator treated as thousand separator, eg if value is 9121.4532 then on some pcs it will be 9121,4532
my question is its my app fault or that pc fault ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: is its my app fault or that pc fault ?
There's no spoon fault. It all depends on the standards and formats set up in a computer. Assuming Windows XP, in Control Panel, have a look at Regional Options -> Standards and Formats -> Customize -> "Digit grouping Symbol" and "Decimal Symbol".
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
thanks mate, shukria dost xD
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|