我记得几周前,当我重新编写代码并在我们的项目中创建了一些命名空间时,我收到了错误,系统不允许我创建companyName.projectName.System命名空间,我不得不将其更改为companyName.projectName.Systeminfo.我不知道为什么.我知道有一个System名称空间,但事实并非如此companyName.projectName.System.我认为A.B.C命名空间应该与A.A.C命名空间不同.对?
编辑
我得到的错误就像这样:
Error 7 The type or namespace name 'Windows' does not exist in the namespace 'MyCompany.SystemSoftware.System' (are you missing an assembly reference?) C:\workspace\SystemSoftware\SystemSoftware\obj\Release\src\startup\App.g.cs 39 39 SystemSoftware
Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio 2008来创建一个DLL.但是找不到相应的.lib文件.为什么?我需要该文件将其放入我的测试仪中.
我的朋友有以下app.config.他想得到的价值address.怎么做?
<configuration>
<system.serviceModel>
...
<client>
<endpoint address="http://ldo:8080/LLService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ILLService" contract="LLServiceReference.ILLService"
name="WSHttpBinding_ILLService">
<identity>
<userPrincipalName value="ggldoe@mail.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
...
</configuration>
Run Code Online (Sandbox Code Playgroud) 在我们的自定义C#日志系统中,我们使用streamWriter = File.CreateText(fileNameStr);创建文件并打开要写入的流.
现在我们要监视文件大小以查看它是否达到所需的最大大小.我做的是以下内容:
currFileInfo = new FileInfo(fileNameStr);curFileInfo.Refresh(); fileSize = curFileInfo.Length;我打印出来看看刷新FileInfo需要多长时间,多次需要大约15毫秒.
所以我想可能有更好的方法来做到这一点.你的建议是什么?
考虑一个MessageBox来提示用户回答是或否.它适用于我们的XP机器和一台Windows 7构建机器.
但是,它不适用于我们的Windows 7 Embedded机器.没有错误消息,没有MessageBox显示.它只是假设用户单击了Yes按钮,因为我可以找到从那里创建的调试文件,并且createDatabase();在没有任何messageBox之前调用它.
我可以找到MessageBox所需的程序集(System.Windows.Forms.dll).它与我们的Windows 7构建机器位于同一位置.你知道为什么吗?谢谢
DialogResult result = System.Windows.Forms.MessageBox.Show(
"Do you want to update your database?\nWarning: All your data will be erased if you click Yes !",
"Update Database",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string[] cmdLines2 = { @"C:\AndeDB\AndeDB.db is here and selected yes" };
//it will create, open and write or overwrite
File.WriteAllLines(@"C:\Temp\dbcheck2.txt", cmdLines2);
createDatabase();
}
Run Code Online (Sandbox Code Playgroud) 我们有不同的方法来终止正在运行的 C# 程序。
也许更多。
我在这里问的是如何在我的 C# 程序中处理它们以保证我的 C# 程序在可能的情况下正常退出。我知道如何捕获 ctrl + C,但其他人不知道。你能帮助我吗?谢谢,
我试图在数据库服务器关闭时捕获数据库异常.我们使用Sybase IAnywhere.
我使用常规的C#try catch来获取数据库异常的名称.
try
{
//code here
}
catch (Exception ex)
{
Logging.Log.logItem(LogType.Exception, "Exception in isDBRunning", "App_Startup::isDBRunning() ", "GetBaseException=" + ex.GetBaseException().ToString() + "\nMessage=" + ex.Message + "\nStackTrace: " + ex.StackTrace + "\nInnerException: " + ex.InnerException);
}
Run Code Online (Sandbox Code Playgroud)
打印例外是这样的:
GetBaseException=iAnywhere.Data.SQLAnywhere.SAException: Database server not found
at iAnywhere.Data.SQLAnywhere.SAConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
Message=The underlying provider failed on Open.
StackTrace: at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open() …Run Code Online (Sandbox Code Playgroud) 我们使用C#实现了一个消息队列Queue.我们知道我们只有一个消费者从队列中取出可用消息以进行while循环处理.我们也知道只有一个生产者将消息放入队列.
我们有一个lock上面的消息队列,以确保消费者和生产者不能同时访问队列.
我的问题是lock必要的吗?如果在实际添加项目之后Queue增加其Count属性,并且如果消费者在检索之前检查,则消费者应该获得完整的消息项,即使我们没有.对?因此,我们不会面临部分邮件项目问题.那我们可以摆脱那个?Countlocklock
这lock将减慢系统速度,偶尔我们可以看到检索线程被阻塞一段时间,因为我们有一个非常重的生产者.
编辑:
不幸的是我们正在使用.Net 3.5.
我有以下声明:
float diff = tempVal - m_constraint.getMinVal();
Run Code Online (Sandbox Code Playgroud)
tempVal被声明为浮点型并且getMinVal()返回浮点值。
我有以下打印输出:
diff=0.099999905,tempVal=5.1,m_constraint.getMinVal()=5.0
我预计差异是0.1,但不是上面的数字。怎么做?
我正在使用Fedora 20.我需要在启动结束时运行两行bash脚本.我想让它在每次机器启动时自动运行.我怎样才能做到这一点?
我试过"sudo crontab -e"来插入我的可执行脚本,但它总是给我错误,告诉我时间不对,无法修改文件.