我有一个C#windows服务安装在我想调试的32位Windows Server 2003机器上.
我遇到的问题是日志文件错误消息告诉我以下内容:
System.NullReferenceException: Object reference not set to an instance of an object.
at VideoProcessor.ResetCameraProperties(DataServiceObject dso)
at VideoProcessor.AddServer(DataServiceObject dso)
at VideoProcessor.LoadServers()
at VideoProcessor.Start()
atVideoServerComponent.Connect()
Run Code Online (Sandbox Code Playgroud)
ResetCameraProperties函数的实际代码是:
protected void ResetCameraProperties(DataServiceObject dso)
{
// Find the CameraType.
//Type videoCameraType = TypeManager.Instance["XFire.Common.VideoObjects.VideoServer"];
if (_videoCameraType == null) return;
//Load cameras from the Data Service Layer
string whereClause = "ServerID = ?";
object[] args = new object[] { dso["ObjectID"] };
IDataServiceCollection videoCameraDsoCollection = ClientServerConnection.Instance.FindCollection(_videoCameraType, whereClause, args, null, CollectionOptions.FilterByPartitionResponsibility) as IDataServiceCollection;
if (videoCameraDsoCollection == null …Run Code Online (Sandbox Code Playgroud) 我正在使用curl与服务器进行通信。
当我请求数据时,我收到HTTP标头,后跟jpeg数据,并用边界将其分隔开,如下所示:

我需要解析
我已经将输入数据复制到一个char数组中,如下所示:
static size_t OnReceiveData ( void * pvData, size_t tSize, size_t tCount, void * pvUser )
{
printf("%*.*s", tSize * tCount, tSize * tCount, pvData);
char* _data;
if(pvData != nullptr && 0 != tCount)
{
_data = new char[tCount];
memcpy(_data, pvData, tCount);
}
return ( tCount );
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能最好地用C ++做到这一点?我实际上如何检查并解析_data数组以获得所需的信息?我可以使用任何增强库吗?
我有一个ActiveX COM对象,用于播放视频及其在C#应用程序中使用.声明如下:
private AxVIDEOPLAYERUILib.AxVideoPlayerUI axVideoPlayerUI;
Run Code Online (Sandbox Code Playgroud)
在我的代码中有锁定就像这样:
lock (axVideoPlayerUI)
{
axVideoPlayerUI.EnableControls = 1;
axVideoPlayerUI.Visible = true;
axVideoPlayerUI.ShowOverlay = 1;
axVideoPlayerUI.OverlayPosition = 3;
axVideoPlayerUI.Play();
}
Run Code Online (Sandbox Code Playgroud)
但我得到警告,我想摆脱:
警告1 CA2002:Microsoft.Reliability:'VideoPlayerControl.LoadRecording(RecordVideo,int)'锁定'AxVideoPlayerUI'类型的引用.将其替换为具有强身份的对象的锁定.
从此链接http://msdn.microsoft.com/en-us/library/ms182290.aspx它指出以下对象具有弱标识:
MarshalByRefObject,ExecutionEngineException,OutOfMemoryException,StackOverflowException,String,MemberInfo,ParameterInfo,Thread.
但我的目标不属于任何这些类别.
我也试过让我的对象静态,如下所述:C#lock和代码分析警告CA2002,但这给了我错误:
错误1无法使用实例引用访问成员"MyNameSpace.VideoPlayerControl.axVideoPlayerUI"; 用类型名称来限定它
有谁知道我怎么能摆脱原来的警告?
我有一个WPF应用程序,它有一个主窗口和几个我导航到的页面,如下所示:
例如,从一页到另一页,我使用:
NavigationService.Navigate(new MyPage1());
Run Code Online (Sandbox Code Playgroud)
从我的主窗口显示我使用的页面:
_mainFrame.Navigate(new PageHome());
Run Code Online (Sandbox Code Playgroud)
我在MainWindow上有一个公共函数,我想从内页调用.
我该怎么做呢??
我有以下类开始一个新的std :: thread.我现在希望线程访问该类的成员变量.到目前为止,我无法弄清楚如何做到这一点.在我的MyThread函数中,我想检查m_Continue.
我已经尝试在创建线程时传入'this'但是我收到错误:
错误1错误C2197:'void(__ cdecl*)(void)':调用c:\ program files(x86)\ microsoft visual studio 11.0\vc\include\functional 1152 1 MyProject的参数太多.
class SingletonClass
{
public:
SingletonClass();
virtual ~SingletonClass(){};
static SingletonClass& Instance();
void DoSomething();
private:
static void MyThread();
std::thread* m_Thread;
bool m_Continue;
};
SingletonClass::SingletonClass()
{
m_Continue = true;
m_Thread= new std::thread(MyThread, this);
}
void SingletonClass::MyThread()
{
while(this->m_Continue )
{
// do something
}
}
void SingletonClass::DoSomething()
{
m_Continue = false;
}
SingletonClass& SingletonClass::Instance()
{
static SingletonClass _instance;
return _instance;
}
int _tmain(int argc, _TCHAR* argv[])
{ …Run Code Online (Sandbox Code Playgroud) 我有一个这样的分组
var myGroups = dataItems.GroupBy(item => item.ItemType);
Run Code Online (Sandbox Code Playgroud)
如何检查 myGroups 中是否存在密钥?
我在 wpf 应用程序中创建了一个用户控件。我像这样使用它:
<Page x:Class="InstallerToolkit.Pages.PageVideosNvr"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:my="clr-namespace:MyProject.UserControls"
mc:Ignorable="d"
d:DesignHeight="525" d:DesignWidth="1050"
Title="PageVideos">
<Grid>
<my:UserControlVideoPlayer Name="VideoPlayer" Margin="559,74,35,155">
</my:UserControlVideoPlayer>
</Grid>
Run Code Online (Sandbox Code Playgroud)
现在在我的 C# 页面中,我想访问它,但是当我在 c# 页面后面的代码中键入它的名称时,VideoPlayer 对象没有出现。
当我想设置它的属性之一时,我该怎么做才能访问它。
我的ASP.Net网站上有以下HTML:
<tr>
<td><asp:TextBox runat="server" Text="Email" ID="LoginEmail"
CssClass="usernamepassword" Width="160px"></asp:TextBox></td>
<td><asp:RequiredFieldValidator runat="server" ID="reqLoginEmail" ControlToValidate="LoginEmail" ValidationGroup="Login" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
<td><asp:TextBox runat="server" Text="Password" ID="LoginPassword"
TextMode="Password" CssClass="usernamepassword" Width="130px" ></asp:TextBox></td>
<td><asp:RequiredFieldValidator runat="server" ID="reqPassword" ControlToValidate="LoginPassword" ValidationGroup="Login" ErrorMessage="*" Display="Static"></asp:RequiredFieldValidator></td>
<td><asp:LinkButton runat="server" ID="btnLogin" OnClick="btnLogin_Click" ValidationGroup="Login" Text="Login" class="buttonRyan green medium" > </asp:LinkButton></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
这在Google Chrome中显示正常,如下所示:

但在Internet Explorer上它看起来像这样:

请注意文本框的深度不是很深,如何让IE版本与Chrome相同?(Firefox也很薄)
这是我的css:
.usernamepassword
{
border-style: none;
border-color: inherit;
border-width: medium;
font: 12px/20px "ArialMTRegular", Arial, Helvetica, sans-serif;
color:#3343030;
padding:0px 1px;
}
Run Code Online (Sandbox Code Playgroud) 我有一个包含exe完整路径和exe名称的字符串,如下所示:
mainExePath = "c:\Folder1\Folder2\MyProgram.exe"
Run Code Online (Sandbox Code Playgroud)
我想得到这样的道路:
"c:\Folder1\Folder2\"
Run Code Online (Sandbox Code Playgroud)
我试过这个:
string mainPath = System.IO.Path.GetFullPath(mainExePath);
Run Code Online (Sandbox Code Playgroud)
但是这返回了相同的字符串.
我怎样才能做到这一点?
我从资源文件中存储了所有数据元素,如下所示:
XDocument xDocTranslated = XDocument.Load(TranslatedFile);
var resultTranslated = from item in xDocTranslated.Descendants("data")
select new
{
Name = (string)item.Attribute("name"),
Value = (string)item.Element("value")
};
Run Code Online (Sandbox Code Playgroud)
我有一个字符串列表,我想与上面的结果进行比较,如果匹配,我想存储新的值.
我正在尝试这样的事情:
//Get each string that i want to translate
foreach (var name in StringsToTranslatelist)
{
//Look up the translated value from data extracted from xml file
var value= from entry in resultTranslated
where entry.Name == name; <--this does not work
}
Run Code Online (Sandbox Code Playgroud)
什么是我应该在这里使用的LINQ语句?我如何搜索resultTranslated?