访问和调用外部组件
2005-08-25 23:52
204 查看
访问.NET和COM组件
创建引用 Add Reference
使用 using 关键字
实例化ActiveX控件
添加引用
添加到Toolbox
拖放控件或代码方式
访问Web Service
添加web 引用 Add Web Reference
实例化 webService1 myService = new WebService1();
调用 myService.myMethod();
异步调用
例
public class AsyncDemo
{
WebService1 myService;
public void CallMethodAsynchronously()
{
myService = new WebService1();
System.AsyncCallback myCallBack = new System.AsyncCallback(CallBack);
myService.BeginMyMethod(myCallBack,new object());
}
public void CallBack(IAsyncResult e)
{
string myString;
myString = myService.EndMyMethod(e);
}
}
采用回调方式
public void AsyncDemo()
{
WebService1 myService = new WebService1();
IAsyncResult Async;
//为回调方法创建委托
System.AsyncCallback myCallBack = new System.AsyncCallback(SomeMethod);
Async = myService.BeginMyMethod(myCallBack,new object());
string myString;
//程序暂停,直到调用返回
myString = myService.EndMyMethod(Async);
}
访问Windows API
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern int Beep(int dwFreq, int dwDuration);
创建引用 Add Reference
使用 using 关键字
实例化ActiveX控件
添加引用
添加到Toolbox
拖放控件或代码方式
访问Web Service
添加web 引用 Add Web Reference
实例化 webService1 myService = new WebService1();
调用 myService.myMethod();
异步调用
例
public class AsyncDemo
{
WebService1 myService;
public void CallMethodAsynchronously()
{
myService = new WebService1();
System.AsyncCallback myCallBack = new System.AsyncCallback(CallBack);
myService.BeginMyMethod(myCallBack,new object());
}
public void CallBack(IAsyncResult e)
{
string myString;
myString = myService.EndMyMethod(e);
}
}
采用回调方式
public void AsyncDemo()
{
WebService1 myService = new WebService1();
IAsyncResult Async;
//为回调方法创建委托
System.AsyncCallback myCallBack = new System.AsyncCallback(SomeMethod);
Async = myService.BeginMyMethod(myCallBack,new object());
string myString;
//程序暂停,直到调用返回
myString = myService.EndMyMethod(Async);
}
访问Windows API
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern int Beep(int dwFreq, int dwDuration);
相关文章推荐
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed du
- OpenStack访问请求在各组件之间的调用过程
- 一个OpenStack访问请求在各组件之间的调用过程
- 关于Asp.net调用外部程序的拒绝访问错误
- 定义一个包含私有成员变量和函数的类,再定义一个内部类,在内部类函数中访问外部成员变量,并调用外部函数。在外部类函数中创建内部类对象,调用内部类函数
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed due to the following error: 80070005 拒绝访问)
- 在java中使用Jawin组件访问Windows下的COM组件 java调用ole
- .NET 使用 ODP.NET 组件访问Oracle提示 外部组件发生异常 错误的解决办法
- vue项目遇到的坑(vue项目中的某个组件调用外部js)
- 调用unrar.dll时SEHException外部组件异常的处理
- 【转载】Flex 调用外部JS(中级篇) - Uyang - Photoshop Flash Flex Apollo 教程 组件 开发 源代码
- Vuejs 2.0 子组件访问/调用父组件的方法(示例代码)
- windows 2008 下C#调用office组件访问拒绝的解决方法(failed due to the following error: 80070005 拒绝访问)
- 一个OpenStack访问请求在各组件之间的调用过程
- VUEJS 2.0 子组件访问/调用父组件的 方法
- 访问外部存储中的数据库文件,使用CursorAdapter显示在ListView组件上
- VUEJS 2.0 子组件访问/调用父组件的实例
- js 对象外部访问或者调用问题
- js 对象外部访问或者调用问题
- Sqlserver中设置某个用户只能访问特定的某个试图(给外部调用)其他的没权限设置