小编Anu*_*uya的帖子

将UDP消息广播到所有可用的网卡

我需要向特定的IP和端口发送UDP消息.

由于有3张网卡,

10.1.x.x
10.2.x.x
10.4.x.x
Run Code Online (Sandbox Code Playgroud)

当我发送UDP消息时,我只在一个网络适配器中收到消息...其余的ip没有收到.

我想在发送消息时检查网络适配器.我怎样才能做到这一点?


目前我正在使用以下内容:

IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(LocalIP), 0);
IPEndPoint targetEndPoint = new IPEndPoint(TargetIP, iTargetPort);
UdpClient sendUdpClient = new UdpClient(localEndPoint);
int numBytesSent = sendUdpClient.Send(CombineHeaderBody, CombineHeaderBody.Length, targetEndPoint);
Run Code Online (Sandbox Code Playgroud)

c# udp udpclient multihomed

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

SQL Server错误:字符串或二进制数据将被截断

我的桌子:

log_id                 bigint
old_value                  xml
new_value                  xml
module                 varchar(50)
reference_id           bigint
[transaction]          varchar(100)
transaction_status         varchar(10)
stack_trace                ntext
modified_on                datetime
modified_by                bigint
Run Code Online (Sandbox Code Playgroud)

插入查询:

INSERT INTO [dbo].[audit_log]
           ([old_value],[new_value],[module],[reference_id],[transaction]
           ,[transaction_status],[stack_trace],[modified_on],[modified_by])
     VALUES
            ('asdf','asdf','Subscriber',4,'_transaction',
            '_transaction_status','_stack_trace',getdate(),555)
Run Code Online (Sandbox Code Playgroud)

错误:

Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
Run Code Online (Sandbox Code Playgroud)

这是为什么 ???

sql-server sql-server-2005

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

如何动态创建数据表中的列并为其赋值?

我将不得不在运行时期间在datatable中创建列并为其赋值.我怎么能在vb.net中做到这一点.任何样品请...

vb.net datatable vb.net-2010

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

在c#windows应用程序中找到打开的表单

我正在使用此功能关闭现有表单并打开一个新表单.

如果没有exixting表单,则会抛出错误.

错误:

目标:System.Object MarshaledInvoke(System.Windows.Forms.Control,System.Delegate,System.Object [],Boolean)

消息:在创建窗口句柄之前,无法在控件上调用Invoke或BeginInvoke.

Stack:at System.Windows.Forms.Control.MarshaledInvoke(Control caller,Delegate method,Object [] args,Boolean synchronous)

因此,在关闭表单之前需要检查是否打开任何表单以避免错误.怎么样?

    static public void NewMainForm(Form main, bool ClosePreviousMain)
    {
            if (main != null)
            {
                Global.ActiveForm = main.Text;
                if (ClosePreviousMain & MyContext.curMain != null)
                {
                    MyContext.curMain.FormClosed -= new FormClosedEventHandler(main_FormClosed);
                    //Need to check for any form active and then close the form.
                    MyContext.curMain.Invoke(new Action(MyContext.curMain.Dispose));
                }
                MyContext.curMain = main;
                MyContext.curMain.FormClosed += new FormClosedEventHandler(main_FormClosed);
                MyContext.curMain.ShowDialog();
            }
    }
Run Code Online (Sandbox Code Playgroud)

c# windows winforms

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

如何在c#中避免多个windows窗体实例

如何在c#中避免多个windows窗体实例?我只想运行一个表单实例.因为有可能从我的应用程序的许多页面打开相同的表单.

c# singleton

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

"bin\Debug\Daemon.exe.manifest; bin\Release\Daemon.exe.manifest"是*task的"InputManifest"参数的无效值

错误:

Error 1   "bin\Debug\Daemon.exe.manifest;bin\Release\Daemon.exe.manifest"
Run Code Online (Sandbox Code Playgroud)

是"GenerateApplicationManifest"任务的"InputManifest"参数的无效值.无法将多个项目传递到"Microsoft.Build.Framework.ITaskItem"类型的参数中.守护进程

c#

8
推荐指数
3
解决办法
9423
查看次数

使用winAPI修改另一个应用程序的Windows样式

我的应用程序启动了另一个应用 因此,我想删除使用c#启动的应用程序的标题栏.

我怎么能这样做,从下面的代码开始?

//Get current style
lCurStyle = GetWindowLong(hwnd, GWL_STYLE)

//remove titlebar elements
lCurStyle = lCurStyle And Not WS_CAPTION
lCurStyle = lCurStyle And Not WS_SYSMENU
lCurStyle = lCurStyle And Not WS_THICKFRAME
lCurStyle = lCurStyle And Not WS_MINIMIZE
lCurStyle = lCurStyle And Not WS_MAXIMIZEBOX

//apply new style
SetWindowLong hwnd, GWL_STYLE, lCurStyle

//reapply a 3d border
lCurStyle = GetWindowLong(hwnd, GWL_EXSTYLE)

SetWindowLong hwnd, GWL_EXSTYLE, lCurStyle Or WS_EX_DLGMODALFRAME

//redraw
SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED
Run Code Online (Sandbox Code Playgroud)

c#

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

如何使用Windows API删除应用程序的MenuBar?

我使用以下代码删除应用程序的标题栏,这对记事本非常有效.现在我想删除菜单栏.怎么实现呢?

  //Finds a window by class name
        [DllImport("USER32.DLL")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        //Sets a window to be a child window of another window
        [DllImport("USER32.DLL")]
        public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        //Sets window attributes
        [DllImport("USER32.DLL")]
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

        //Gets window attributes
        [DllImport("USER32.DLL")]
        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

        [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);


        //assorted constants needed
        public …
Run Code Online (Sandbox Code Playgroud)

c# api winapi

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

如何使用c#从Bios获取CPU温度信息?

如何使用c#从Bios获取CPU温度信息我尝试了CPU温度监控中的代码

但没有运气.'enumerator.Current'引发了异常.

我怎样才能实现这一目标?谢谢.

错误:

"此系统不支持所需的WMI对象(1) - 检查异常文件\ r \n是否支持\ r \n\r \n在系统管理.管理异常.ThrowWithExtendedInfo(ManagementStatus errorCode)\ r \n在系统中.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()\ r \n在CedarLogic.WmiLib.SystemStatistics.RefreshReadings()的D:\ Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:第25行\ r \n在CedarLogic.WmiLib .SystemStatistics.get_CurrentTemperature()位于D:\ Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:第87行\ r \n,位于D:\ Downloads\TempMonitorSrc\TemperatureMonitorSln\TemperatureMonitor\SystemTrayService中的TemperatureMonitor.SystemTrayService.CheckSupport(). cs:260行"

c# monitor temperature

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

web.config的appsettings值内的标签.怎么样?

 <appSettings>
    <add key="CodeNF" value="somevalue"/>
  </appSettings>

In the above code, i need to put value="<somevalue>".
Run Code Online (Sandbox Code Playgroud)

是否可以在我的web.comfig中执行此操作?谢谢

.net xml web-config

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