C#编写Com组件
1、新建一个类库项目
2、将Class1.cs改为我们想要的名字
问是否同时给类改名,确定
3、修改Properties目录下面的AssemblyInfo.cs
ComVisible属性设置为True
4、项目菜单->MyLib属性
找到“生成”选项卡
往下看,找到“为 COM Interop 注册”勾上
5、继续往下,找到“签名”选项卡
勾上“为程序集签名”
在下面的下拉框里面选择“ <新建...>”
6、在弹出的对话框里面,输入MyLib。。或者随便取个名字
去掉使用密码保护文件的选项
7、开始编码,任何一个公开的类,必须有一个 I开通的接口定义
C# code
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyLib
{
[ComVisible(true)]
[Guid("2CBD3D76-35F1-4f9d-9C1B-9DBFEE412F76")]
public interface IMyClass
{
void Initialize();
void Dispose();
int Add(int x, int y);
}
[ComVisible(true)]
[Guid("EA2F140A-108F-47ae-BBD5-83EEE646CC0D")]
[ProgId("MyLib.MyClass")]
public class MyClass : IMyClass
{
public void Initialize()
{
//nothing todo
}
public void Dispose()
{
//nothing todo
}
public int Add(int x, int y)
&
相关文档:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Office.Inter ......
环境:ASP.NET(C#),Visual Studio 2010。
提示:未能加载类型“EMS.App_Code.PersonalInfo”。如果该类型位于App_Code文件夹中,请检查它是否已编译。如果该类型位于已编译的程序集中,请检查该程序集是否被该项目引用。
处理:
自己做得一个小程序,取名EMS,并在App_Code文件夹下建立了类PersonalInfo、Sal ......
在做asp.net的Web开发的时候,我们经常会遇到一次性上传多个文件的需求。通常我们的解决方法是固定放多个上传文件框,这样的解决办法显然是不合理的,因为一次上传多个,就意味着数量不确定。因此我们就要让这些文件上传框动态添加,下面我以我做的一个图库管理中的上传图片的功能为例
先看效果:
打开的初始界面:
默认 ......
public void SetWindowRegion()
{
System.Drawing.Drawing2D.GraphicsPath FormPath;
FormPath =
new System.Drawing.Drawing2D.GraphicsPath();
Rectangle
rect=ne ......
之前不太喜欢C#,无意中发现linq,用来实现排序是如此简单,所以又用C#写了遍发牌程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
&nb ......