需要从命令行运行C#dll [英] Need to run a c# dll from the command line

查看:172
本文介绍了需要从命令行运行C#dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样定义的c#dll:

I have a c# dll defined like this:

namespace SMSNotificationDll
{
    public class smsSender
    {
        public void SendMessage(String number, String message)
        {
            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "c:\\Program Files\\Java\\jdk1.6.0_24\\bin\\java";
            info.WorkingDirectory = "c:\\";
            info.Arguments = "-jar SendSms.jar "+number + " "+message;
            info.UseShellExecute = false;
            Process.Start(info);
        }
    }
}

我需要从命令行执行它.

and i need to execute it from the commandline.

有什么办法可以通过rundll32运行它吗?

Is there any way I can run it through rundll32?

当我用它运行它时:

rundll32 SMSNotificationDll.dll, SendMessage 0749965244 hello

我丢失了条目:SendMessage.

I get missing entry: SendMessage.

推荐答案

为什么不创建一个简单的控制台应用程序,将DLL称为类库?

Why don't you just create a simple console application which refers to the DLL as a class library?

namespace SMSNotificationDll
{
    public class SmsSenderProgram
    {
        public static void Main(string[] args)
        {
            // TODO: Argument validation
            new smsSender().SendMessage(args[0], args[1]);
        }
    }
}

顺便说一句,我将smsSender重命名为SmsSender之类.

Btw, I'd rename smsSender to something like SmsSender.

这篇关于需要从命令行运行C#dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆