小编Cip*_*her的帖子

无法在DLL中找到入口点

我有一个C#应用程序,我试图将参数发送到C++函数.但是,我收到了错误(在主题中提到)

C#应用程序:

static class SegmentationFunctions
{
[DllImport("MyApplication.dll", EntryPoint = "fnmain", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern int fnmain(string search);
    }
}

public partial class MainWindow:Window
{
public MainWindow()
{
InitializeComponent();

string search = "test string here";
int scommand = SegmentationFunctions.fnmain(search);
}
Run Code Online (Sandbox Code Playgroud)

C++ file.h

extern "C" QUERYSEGMENTATION_API int fnmain(char query[MAX_Q_LEN]);
Run Code Online (Sandbox Code Playgroud)

C++文件.cpp

extern "C" QUERYSEGMENTATION_API int fnmain(char searchc[MAX_LEN_Q])
{

do something...

}
Run Code Online (Sandbox Code Playgroud)

c# c++ visual-c++

4
推荐指数
1
解决办法
7456
查看次数

每天使用 TraceSource 写入新的日志文件

我在应用程序中使用记录器来写入文件。源、开关和侦听器已在 app.config 文件中定义,如下所示:

  <system.diagnostics>
    <sources>
      <source name="LoggerApp" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="myListener.log" />
        </listeners>
      </source>
    </sources>
    <switches>
      <add name="sourceSwitch" value="Information" />
    </switches>
  </system.diagnostics>
Run Code Online (Sandbox Code Playgroud)

在我的 .cs 代码中,我使用记录器如下:

private static TraceSource logger = new TraceSource("LoggerApp");
logger.TraceEvent(TraceEventType.Information, 1, "{0} : Started the application", DateTime.Now);
Run Code Online (Sandbox Code Playgroud)

我需要做什么才能每天创建一个新的日志文件而不是每次都写入同一个日志文件?

c#

4
推荐指数
1
解决办法
4073
查看次数

当dr中没有数据时读取的尝试无效

我想在我的ASP.NET网站上创建一个登录表单.目前,存在一些问题.我正在尝试合并功能,以便登录用户具有仅查看其个人资料的优势.登录页面上的代码是这样的:

business.clsprofiles obj = new business.clsprofiles();
        Int32 a = obj.logincheck(TextBox3.Text, TextBox4.Text);
        if (a == -1)
        {
            Label1.Text = "Username/Password incorrect";
        }
        else
        {
            Session["cod"]= a;
            Response.Redirect("profile.aspx");
        }
Run Code Online (Sandbox Code Playgroud)

登录后,用户将被移动到该人员登录后可以查看其个人资料的页面.会话正在从登录页面正确获取登录人员的值,并成功将其传递到下一页.但是在这个配置文件页面上发生错误,我认为grid_bind()下面的方法中存在问题

public void grid_bind()
{
    business.clsprofiles obj = new business.clsprofiles();
    List<business.clsprofilesprp> objprp = new List<business.clsprofilesprp>();
    Int32 z = Convert.ToInt32(Session["cod"]);
    objprp = obj.fnd_profiles(z); //This line of code is passing an integer as required but does not get the desired result from the database
    GridView1.DataSource = objprp;
    GridView1.DataBind();
}
Run Code Online (Sandbox Code Playgroud)

正如业务逻辑中的错误所述,"当dr中没有数据时无效的读取尝试"

public List<clsprofilesprp> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net datareader no-data

3
推荐指数
1
解决办法
1万
查看次数

逗号附近的语法不正确

这是我尝试从会话中获取多个值时的ASPX代码段.我收到一个错误:"逗号附近的语法不正确"(标记在代码段中的行):

SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]), con);
        SqlDataReader dr1 = cmd1.ExecuteReader();
        var yourlist =new List<Int32>();
        if (dr1.HasRows)
        {
            while (dr1.Read())
            {
                yourlist.Add(Convert.ToInt32(dr1[0]));
            }
        }

        //String str1 = String.Join(", ", yourlist.Select(o => o.ToString()).ToArray());
            dr1.Close();
        cmd1.Dispose();
        Array k= yourlist.ToArray();
        Int32 a =Convert.ToInt32( k.GetValue(0));
        Int32 b =Convert.ToInt32( k.GetValue(1));
        Int32 c =Convert.ToInt32( k.GetValue(2));
        Int32 d =Convert.ToInt32( k.GetValue(3));
        SqlCommand cmd2 = new SqlCommand("select id,name from plugins where id =(" + a + " or " + b + …
Run Code Online (Sandbox Code Playgroud)

sql asp.net

3
推荐指数
1
解决办法
1079
查看次数

SiteMapPath 未出现

我添加了一个 Web.sitemap 并将 siteMapNode 添加到它。此外,我已将asp:SiteMapPath控件放在网页上,但在运行时没有显示任何内容。

这是我的 SiteMapPath 控件的代码:

<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em">
    <CurrentNodeStyle ForeColor="#333333" />
    <NodeStyle Font-Bold="True" ForeColor="#666666" />
    <PathSeparatorStyle Font-Bold="True" ForeColor="#1C5E55" />
    <RootNodeStyle Font-Bold="True" ForeColor="#1C5E55" />
</asp:SiteMapPath>
Run Code Online (Sandbox Code Playgroud)

SiteMapPath 不自动控制拾取 Web.sitemap 吗?或其他任何东西如果离开?如果要检查 Web.sitemap,这里是

.net sitemap asp.net

3
推荐指数
1
解决办法
4042
查看次数

将多个值存储在会话变量中

在我提出问题之前,请考虑以下情况:我网站上的用户有一个profileID.有一些pluginID与此相关profileID.

例如:User1可能有2个,3个和5个插件与他的个人资料相关联.

当用户登录时,我将profileID用户存储在会话变量中cod.在某个页面上,用户尝试编辑plugins与其个人资料相关联的内容.所以,在那个页面上,我必须pluginID从数据库中检索它们.

我已经应用了这段代码,但这只pluginID取得了DB 的最大值,而不是所有pluginID的.

SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where id=(select id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]) + ")", con);
SqlDataReader dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
  while (dr1.Read())
  {
    Session["edp1"] = Convert.ToInt32(dr1[0]);
  }
}
dr1.Close();
cmd1.Dispose();
Run Code Online (Sandbox Code Playgroud)

我试图找出如何pluginID在此会话变量中存储多个?

谢谢

.net c# asp.net

2
推荐指数
1
解决办法
8970
查看次数

无效的对象名称'umbracoDomains'

我将Umbraco CMS的所有文件上传到我的http://blog.domain.com,并修改了web.config文件.当我指向blog.domain.com时,它会在主题中写入错误.子域的托管类型是物理托管,而不是子文件夹上的子域

所以,我在这个子域中有第二个web.config文件.第一个是在主域.我觉得这不会有所不同.这是截图:http://i.stack.imgur.com/PxSqq.jpg

我检查了我尝试登录到数据库的数据库用户,它具有数据库的db_owner权限.

此外,我尝试谷歌搜索类似的问题,看看有类似错误的人是否解决了这个问题.这是一些页面,但我找不到解决方案.请帮忙!这已经很久了!:-(

asp.net umbraco

2
推荐指数
1
解决办法
4630
查看次数

防止注册表输入代码要求管理员优先权

在我的应用程序中,我试图通过使用以下代码添加注册表项来将我的应用程序设置为启动:

RegistryKey startupapp = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
startupapp.SetValue("App", "\"" + Assembly.GetExecutingAssembly().Location + "\"" +" -start");
Run Code Online (Sandbox Code Playgroud)

但问题是只有在我以管理员身份运行我的应用程序时才会添加注册表.有什么方法我可以避免这个事情,以便我的应用程序可以添加/删除启动应用程序的注册表项?

c# registry wpf

2
推荐指数
1
解决办法
1155
查看次数

错误:预期')'在'''令牌|之前

我正在实现一个String并在.h文件中给出定义.String.h中的代码如下:

#include<list>
class String
{
    public:
    String();//Constructor
    String(char * copy);//For converting CString to String
    const char *c_str(const String &copy);//For converting String to Cstring
    String(list<char> &copy);//Copying chars from list
    //Safety members
    ~String();
    String(const String &copy);
    void operator = (const String &copy);
    protected:
    int length;
    char *entries;
};
Run Code Online (Sandbox Code Playgroud)

主题中提到了错误.我不遵循的是什么?

c++

1
推荐指数
1
解决办法
568
查看次数

给出两点,找到第三点

我有两点A (x1,y1),B (x2,y2)作为程序的输入.我必须找到第三个C位于线上AB并且距离10A点一点的点.

我可以很容易地得到线的斜率,但这并没有给出线的完整方程.即使我得到完整的等式,我也不确定使用这个等式,我怎样才能找到x距离A的距离.

有关如何处理此问题的任何建议?

c++ algorithm

1
推荐指数
1
解决办法
7353
查看次数

无法从'System.Collections.Generic.List <business.clspluginsprp>'转换为'business.clspluginsprp

我试图以下面的方式在Grid View中显示数据,但是我收到了这个错误.

List<business.clspluginsprp> objprp = new List<business.clspluginsprp>();
business.clsplugins obj = new business.clsplugins();

for (Int32 i = 0; i < k.Length; i++)
{

    Int32 z = Convert.ToInt32(k.GetValue(i));
    objprp.Add(obj.fnd_plugins(z));

}

GridView2.DataSource = objprp;
GridView2.DataBind();
Run Code Online (Sandbox Code Playgroud)

我真的不是ASP.NET的专家.请帮助解决此错误.编辑 - 活动的完整代码http://pastebin.com/pX2mNRna

.net c#

0
推荐指数
1
解决办法
622
查看次数

应用程序的两种启动行为

我有一个应用程序,我希望有两种不同的启动行为.
例如:如果用户从桌面或应用程序快捷方式运行应用程序,则应运行应用程序并请求输入.

但是,我的应用程序也被设置为启动应用程序.如果应用程序在计算机重启时自动启动,它不应该要求用户输入并且具有不同的流程(因为它将记住首选项)

如何实现这种行为?也许,我正在考虑有两个不同的构造函数重载,这将在两个案例中做不同的事情.但是,如何选择在适当的时间运行哪个构造函数(启动应用程序运行/桌面应用程序运行)?
如何在WPF中完成?

c# wpf

0
推荐指数
1
解决办法
88
查看次数

标签 统计

c# ×7

asp.net ×5

.net ×3

c++ ×3

wpf ×2

algorithm ×1

datareader ×1

no-data ×1

registry ×1

sitemap ×1

sql ×1

umbraco ×1

visual-c++ ×1