Open liligaga opened 4 years ago
using System.Text; using com.alibaba.rocketmq.client.producer; using com.alibaba.rocketmq.common.message;
namespace rocket_mq_client_demo { class Program {
static void Main(string[] args)
{
DefaultMQProducer p = new DefaultMQProducer("test");
p.setNamesrvAddr("192.168.100.3:9876");
p.setProducerGroup("test");
p.start();
var data = Encoding.UTF8.GetBytes("234455");
Message m = new Message("defaulttopic1", data);
p.send(m);
// p.shutdown();
}
}
}
jdk版本不对吧。你用的是哪个版本的jdk?
我用的jdk11,这个项目能不能在mac上运行呢,这个问题说找不到包: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, 我加载了这个包出现了新的问题
Unhandled exception. System.TypeInitializationException: The type initializer for 'com.alibaba.rocketmq.remoting.common.RemotingUtil' threw an exception.
---> System.MissingMethodException: Method not found: 'Void System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.Security.AccessControl.FileSystemRights, System.IO.FileShare, Int32, System.IO.FileOptions)'.
at IKVM.NativeCode.java.io.FileDescriptor.open(String name, FileMode fileMode, FileAccess fileAccess)
at java.io.FileDescriptor.open(String , FileMode , FileAccess )
at java.io.FileDescriptor.open(String , Int32 , Int32 )
at java.io.FileDescriptor.openReadOnly(String )
at java.io.RandomAccessFile.open(String , Int32 )
at java.io.RandomAccessFile..ctor(File file, String mode)
at java.util.zip.ZipFile..ctor(File file, Int32 mode, Charset charset)
at java.util.zip.ZipFile..ctor(File file, Int32 mode)
at java.util.zip.ZipFile..ctor(String name)
at IKVM.Internal.VirtualFileSystem.Initialize()
at IKVM.Internal.VirtualFileSystem.GetVfsEntry(String name)
at IKVM.Internal.VirtualFileSystem.GetBooleanAttributes(String path)
at IKVM.NativeCode.java.io.Win32FileSystem.getBooleanAttributes(Object _this, File f)
at IKVM.NativeCode.java.io.UnixFileSystem.getBooleanAttributes0(Object _this, File f)
at java.io.UnixFileSystem.getBooleanAttributes0(File )
at java.io.UnixFileSystem.getBooleanAttributes(File )
at java.io.File.isDirectory()
at java.io.File.toURI()
at IKVM.Internal.AssemblyClassLoader.MakeResourceURL(Assembly asm, String name)
at IKVM.Internal.AssemblyClassLoader.AssemblyLoader.FindResources(String name)
at IKVM.Internal.AssemblyClassLoader.
建议安装jdk8再试试,目前应该是不支持.net core
Unhandled exception. System.TypeInitializationException: The type initializer for 'java.lang.ProcessEnvironment' threw an exception. ---> System.TypeInitializationException: The type initializer for 'sun.misc.VM' threw an exception. ---> System.TypeInitializationException: The type initializer for 'java.lang.Props' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at java.lang.VMSystemProperties.initProperties(Properties ) at java.lang.Props..cctor()
--- End of inner exception stack trace --- at java.lang.System.lineSeparator() at sun.misc.VM..cctor() --- End of inner exception stack trace --- at sun.misc.VM.isBooted() at sun.misc.Hashing.randomHashSeed(Object instance) at java.util.HashMap..ctor(Int32 initialCapacity, Single loadFactor) at java.util.HashMap..ctor() at java.lang.ProcessEnvironment..ctor() at java.lang.ProcessEnvironment..cctor() --- End of inner exception stack trace --- at java.lang.ProcessEnvironment.getenv(String ) at java.lang.System.getenv(String name) at com.alibaba.rocketmq.client.ClientConfig..ctor() at com.alibaba.rocketmq.client.producer.DefaultMQProducer..ctor(String producerGroup, RPCHook rpcHook) at com.alibaba.rocketmq.client.producer.DefaultMQProducer..ctor(String producerGroup) at rocket_mq_client_demo.Program.Main(String[] args) in /Users/zhangli/Projects/rocket_mq_client_demo/rocket_mq_client_demo/Program.cs:line 14 bash: line 1: 47146 Abort trap: 6 "/usr/local/share/dotnet/dotnet" "/Users/zhangli/Projects/rocket_mq_client_demo/rocket_mq_client_demo/bin/Debug/netcoreapp3.0/rocket_mq_client_demo.dll"
Press any key to continue...