首页 \ 问答 \ 尝试运行Apache Solr时访问被拒绝(Access denied when trying to run Apache Solr)

尝试运行Apache Solr时访问被拒绝(Access denied when trying to run Apache Solr)

我正在尝试启动Apache solr但它返回Access被拒绝。

附件


I am trying to start the Apache solr But it returns Access denied.

attachment


原文:https://stackoverflow.com/questions/40715183
更新时间:2023-02-09 20:02

最满意答案

Console.WriteLine()仅打印终端中的第一个字母(“t”)。 这是什么问题?

你只复制了一个字符:

*a_str = *pp;

相反,您需要复制整个字符串:

strcpy(a_str, pp);

当然,您只是要求使用此代码发生缓冲区溢出错误。 调用函数时,还需要传递缓冲区的长度,并安排不要复制超出该缓冲区的末尾。

我在C#中分配内存(使用StringBuilder)。 在我的情况下C#GC是否释放内存,或者我必须手动释放内存以及在哪一侧(C或C#)。

传递给C ++代码的内存由p / invoke框架管理,它确保正确分配和释放它。 您不需要再做任何事情了。


从您提供的代码,似乎该函数使用__cdecl调用约定。 将CallingConvention = CallingConvention.Cdecl添加到您的DllImport属性:

[DllImport("Serializer", CharSet = CharSet.Ansi, 
    CallingConvention = CallingConvention.Cdecl)]

Console.WriteLine() prints only first letter("t") in terminal. What is this issue?

You only copied one character here:

*a_str = *pp;

Instead you need to copy the entire string:

strcpy(a_str, pp);

Of course, you are simply asking for a buffer overrun error with this code. You need to also pass the length of buffer when you call the function, and arrange that you do not copy beyond the end of that buffer.

I am allocating memory in C#(using StringBuilder). Is C# GC deallocating memory in my case or do i have to deallocate memory manually and in which side(C or C#).

The memory passed down to the C++ code is managed by the p/invoke framework, and it ensures that it is allocated and deallocated correctly. You do not need to do anything more.


From the code you present, it seems that the function uses the __cdecl calling convention. Add CallingConvention = CallingConvention.Cdecl to your DllImport attribute:

[DllImport("Serializer", CharSet = CharSet.Ansi, 
    CallingConvention = CallingConvention.Cdecl)]

相关问答

更多
  • 如果要在右侧填充值,则需要对字段宽度使用负值: $"Row {csv.Row, -10}, {ex.Message}" 有关更多详细信息,请参阅复合格式文章 Thanks to the comment of sgmoore, I was able to resolve it. It seems this is an issue of html, where it is not possible to use multiple whitespaces in a row.
  • 尝试使用StringBuilder [DllImport("MyNativeC++DLL.dll")] private static extern int GetInstalledSoftwares(StringBuilder pchInstalledSoftwares); static void Main(string[] args) { ......... ......... StringBuilder b = new StringBuilder(255); GetI ...
  • 听起来你需要确保页面完全加载,就像可能存在竞争条件一样。 我建议连接WebBrowser.DocumentCompleted事件,然后尝试你的报废逻辑。 更新 我最初忽略了这一点,这肯定与你的问题有关。 您正在调用click ,如scraper.clientBrowser.Document.GetElementById(order).InvokeMember("Click"); 。 这是在迭代中完成的,这很可能会操纵DOM - 不会吗? 我建议完全不同于这个问题。 你想要达到的目标是什么,(不是你想要怎么做 ...
  • Console.WriteLine()仅打印终端中的第一个字母(“t”)。 这是什么问题? 你只复制了一个字符: *a_str = *pp; 相反,您需要复制整个字符串: strcpy(a_str, pp); 当然,您只是要求使用此代码发生缓冲区溢出错误。 调用函数时,还需要传递缓冲区的长度,并安排不要复制超出该缓冲区的末尾。 我在C#中分配内存(使用StringBuilder)。 在我的情况下C#GC是否释放内存,或者我必须手动释放内存以及在哪一侧(C或C#)。 传递给C ++代码的内存由p / in ...
  • 会话状态可能是该特定方案的更好选择,因为每当用户登陆WelcomePage时您都需要它。 Session["Parameter"] = datatable.Rows[0].Field(1); // Set a break point at Redirect, and check to make value is assigned // to Session["Parameter"] before redirecting. Response.Redirect("Welcome.aspx") ...
  • 我建议使用char *。 这是一个可能的解决方 如果您创建另一个C#函数ToUpper_2,如下所示 C#方: [DllImport("TestDll.dll"), CallingConvention = CallingConvention.Cdecl] private static extern IntPtr ToUpper(string s); public static string ToUpper_2(string s) { return Marshal.PtrToStringAnsi( ...
  • 在跨P / Invoke边界编组字符串时,最好使用具有相应字符串类型的MarshalAs属性。 我认为在参数上放置一个[MarshalAs(UnmanagedType.BStr)]可以解决这个问题。 public delegate void callback([MarshalAs(UnmanagedType.BStr)]string str); 本文有一个类似的例子,有人在托管代码和非托管代码之间传递BSTR,但他在Marshal类上使用了IntPtr和一些方法。 Marshal.PtrToStringB ...
  • 如果您使用的是C ++ / CLI,则可以直接使用String : void Highlight(double xCoordinate, double yCoordinate, String^ name) { //... If you're using C++/CLI, you can use String directly: void Highlight(double xCoordinate, double yCoordinate, String^ name) { //...