我使用以下代码来引用shell DLL
Type t = Type.GetTypeFromProgID("Shell.Application");
Shell s = (Shell)Activator.CreateInstance(t);
Console.WriteLine("success");
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
它在我的Windows 7开发机器上工作正常.但是当我尝试在Win 2003服务器上运行exe时,我得到了这个异常
Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell3
2.Shell'. This operation failed because the QueryInterface call on the COM compo
nent for the interface with IID '{866738B9-6CF2-4DE8-8767-F794EBE74F4E}' failed
due to the following error: No such interface supported (Exception from HRESULT:
0x80004002 (E_NOINTERFACE)).
Run Code Online (Sandbox Code Playgroud)
我从C#中获得了一些帮助:引用了一个Windows shell界面,但没有运气.
我使用Microsoft Shell控件和自动化引用引用shell,这是Interop.Shell32 dll
如果有人可以指导,那将非常有帮助.
我想知道LINQ通用集合的方法.
我的客户类是
class Customer
{
public string Name { get; set; }
public string id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的收藏课是
class genericCollection<T> : CollectionBase
{
public void add(T GenericObject)
{
this.List.Add(GenericObject);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将一些数据添加到客户集合中
genericCollection<Customer> customers = new genericCollection<Customer>();
customers.add(new Customer {id= "1",Name="Andy"});
customers.add(new Customer { id = "2", Name = "MArk" });
customers.add(new Customer { id = "3", Name = "Jason" });
customers.add(new Customer { id = "4", Name = "Alex" });
Run Code Online (Sandbox Code Playgroud)
现在我可以使用foreach循环遍历客户对象,但我怎么能知道它.
我想用类似的东西
var query = from …
Run Code Online (Sandbox Code Playgroud)