CodeDomProvider objCodeCompiler = CodeDomProvider.CreateProvider( "CSharp" );
CompilerParameters objCompilerParameters = new CompilerParameters();
...
CompilerResults objCompileResults = objCodeCompiler.CompileAssemblyFromFile( objCompilerParameters, files.ToArray() );
Run Code Online (Sandbox Code Playgroud)
当我编译我的文件时,我得到:
FileFunctions.cs(347):错误:意外字符'$'
有没有人知道如何使用CodeDom编译进行字符串插值?
我找到了这个链接:如何使用CSharpCodeProvider定位.net 4.5?
所以我尝试过:
var providerOptions = new Dictionary<string, string>();
providerOptions.Add( "CompilerVersion", "v4.0" );
// Instantiate the compiler.
CodeDomProvider objCodeCompiler = CodeDomProvider.CreateProvider( "CSharp", providerOptions );
Run Code Online (Sandbox Code Playgroud)
但我仍然得到同样的错误.
我还将目标框架更新到.NET Framework 4.6.
注意:我不能指定"v4.5"或"v4.6"或者我会得到:
************** Exception Text **************
System.InvalidOperationException: Compiler executable file csc.exe cannot be found.
at System.CodeDom.Compiler.RedistVersionInfo.GetCompilerPath(IDictionary`2 provOptions, String compilerExecutable)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
at …Run Code Online (Sandbox Code Playgroud) 我可以开始调试了(F5).
如果我从Ctrl + F5开始,然后再去附加我无法.
程序名称显示为灰色.当我选择程序的行时,附加按钮被禁用.
我尝试使用Attach to"Automatic"或者选择Managed 4.0 + Native.
我已经尝试检查"显示所有用户的进程"和"在所有会话中显示进程"
我以管理员身份运行Visual Studio.
有任何想法吗?
尝试使用ODP .NET连接时出现ORA-12154错误
更新:Wernfried的回答为我解决了.
创建一个环境变量TNS_ADMIN = D:\ oracle\product\12.1.0\dbhome_1 \network\admin
Sqlplus从Registry读取TNS_ADMIN但ODP.NET托管驱动程序不读取注册表.另请参阅: OdbcConnection将中文字符返回为"?"
您可以通过以下方式检查环境变量:
string tns_admin = Environment.GetEnvironmentVariable("TNS_ADMIN")
Run Code Online (Sandbox Code Playgroud)
我并没有完全理解他建议的链接是如何相关的.
原始问题:
尝试使用ODP .NET连接时出现ORA-12154错误
代码:
OracleConnection oracleConnection = new OracleConnection();
string connectionString = "User Id=redacted;Password=redacted;Data Source=db6";
oracleConnection.ConnectionString = connectionString;
oracleConnection.Open();
Run Code Online (Sandbox Code Playgroud)
错误:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Oracle.ManagedDataAccess.Client.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified ---> OracleInternal.Network.NetworkException: ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName)
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.Network.OracleCommunication.Connect(String
Run Code Online (Sandbox Code Playgroud)
我的tnsnames.ora:
# tnsnames.ora …Run Code Online (Sandbox Code Playgroud) 我注意到setforegroundwindow可能非常不稳定 - 无论你怎么做.
我注意到在可能的情况下使用UIAutomation似乎可以改善一些事情.
例如:
获取WindowPattern并使用如下内容:
windowPattern.SetWindowVisualState( WindowVisualState.Normal );
windowPattern.SetWindowVisualState( WindowVisualState.Maximized );
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:
我怎么知道我是否应该使它最大化或正常.任务经理和龙自然都说似乎都知道如何做到这一点.如果之前最大化,然后最小化,我想在切换到它时最大化窗口.如果以前没有最大化,我想把它变成"正常".
有任何想法吗?
有没有办法使用 devenv 为命令行构建指定构建详细程度?
我正在尝试进行两次构建我们的解决方案的测试,第二次构建它应该输出:
构建:55 个成功,0 个失败,69 个是最新的,1 个跳过
但实际上应该是 0 成功,x 是最新的。
我正在运行测试,但理想情况下,我会指定使用 verbosity = 诊断为第二个构建进行构建,以便我可以看到为什么要重建。
我知道 msbuild 有一个详细程度标志,我认为没有办法使用 devenv 设置构建详细程度,除非有人可以给我一个偷偷摸摸的方式。
我知道对于构建我们通常应该使用 msbuild,但我认为 devenv 似乎在避免重新编译已经编译的东西方面做得更好。所以我想用它来测试。
我正在使用新的.csproj文件格式。
我希望我的项目构建为:
C:\ Development \ Source \ DotNet \ bin \ x64 \ Debug \
但是它似乎隐式地添加到路径并在以下位置进行构建:
C:\ Development \ Source \ DotNet \ bin \ x64 \ Debug \ net46
有办法防止它这样做吗?
我的项目是:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<Platforms>x64</Platforms>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutputPath>C:\Development\Source\DotNet\bin\x64\Debug\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="AssetManagement_Gen">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\AssetManagement_Gen.dll</HintPath>
</Reference>
<Reference Include="EXPLink">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\EXPLink.dll</HintPath>
</Reference>
<Reference Include="IvaraCommon">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\IvaraCommon.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\NLog.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
如果我在Visual Studio中打开它,它还会显示在输出路径上并附加“ net46”。
对于我的后人,组合<OutputPath>,并<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>可以让你得到一个完全自定义路径。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> …Run Code Online (Sandbox Code Playgroud) 我注意到 yaml 没有显式的签出步骤,并且某些文件被挂起的 testhost 进程锁定,导致失败。
我可以添加以下内容
- task: CmdLine@2
inputs:
script: 'wmic process where name="testhost.exe" call terminate'
condition: always()
Run Code Online (Sandbox Code Playgroud)
到管道运行结束。
想知道是否有办法让它在 git checkout 之前运行。结帐不是 YAML 的一部分。
一点跟进:有没有办法迭代windbg中的所有帧?
~*e .echo Thread Frames and Locals:; !for_each_frame dv
Run Code Online (Sandbox Code Playgroud)
有没有办法回应如下:当前线程#{ThreadID}当前帧#{帧号}
我找不到任何代表当前帧号或线程号的变量.
.frame命令显示当前帧编号.
举个简单的例子:如果我这样做: ~*e .thread
我输出如下:
Implicit thread is now 000007ff`fffde000
Implicit thread is now 000007ff`fffdc000
Implicit thread is now 000007ff`fffd8000
Implicit thread is now 000007ff`fffd6000
Implicit thread is now 000007ff`ffefa000
Run Code Online (Sandbox Code Playgroud)
但我想看看windbg线程ID.同样,我希望看到一个遍历所有线程和框架的示例,并打印如下内容:
当前线程#00当前帧#01
我认为我的问题类似于:
.NET 4.0和可怕的OnUserPreferenceChanged Hang
我也看了看:
http://ikriv.com/en/prog/info/dotnet/MysteriousHang.html#BeginInvokeDance
我删除了我们的启动画面.
我还尝试添加建议的代码:Microsoft.Win32.SystemEvents.UserPreferenceChanged + = delegate {}; 到我们的main()方法.
我正在寻找有关如何排除故障的一些想法和信息.
对于我们的main()方法,我们启动一个windowmanager类,它是一个使用Application.Run的表单.它只是任务栏中的一个图标(我们不显示窗口).
每当我们启动一个对象时,我们都有一个后台线程,它创建一个表单,然后执行Application.Run(form)
在Application.Run(form)form.IsHandleCreated = false时.
我使用MysteriousHang网站上的冰箱应用程序.(我修改它以继续在循环中发送更改通知).
我应该如何处理创建和运行新表单?是否在后台线程上创建表单是否重要,即使它的句柄尚未创建?
我们有一个程序可以作为服务或winforms应用程序运行.我们根据传入的命令行参数执行不同的行为.
如果我们作为表单运行,我想我们希望我们的入口点是STAThread.
CA2232:使用STAThread标记Windows窗体入口点
但是,如果我们作为服务运行,我们希望我们的入口点是MTAThread吗?人们通常如何处理这个问题?
我们发现了一些崩溃转储(作为服务运行时),我们似乎遇到了卡住的终结器.
如果主入口点未标记为STAThread,则不会出现此问题.
线程2:
IP
00:U 00000000779312fa ntdll!NtWaitForSingleObject + 0xa
01:U 000007fefd6d10dc KERNELBASE!WaitForSingleObjectEx + 0x79
02:U 000007fefdd1e68e ole32!GetToSTA + 0x8a
03:U 000007fefde53700 ole32!CRpcChannelBuffer :: SwitchAptAndDispatchCall + 0x13b
04:U 000007fefde5265b ole32!CRpcChannelBuffer :: SendReceive2 + 0x11b
05:U 000007fefdd0daaa ole32!CAptRpcChnl :: SendReceive + 0x52
06:U 000007fefdd1cbe6 ole32!CCtxComChnl :: SendReceive + 0x15c
07:U 000007fefde5205d OLE32 NdrExtpProxySendReceive + 0×45!
08:U 000007fefdb3b949 RPCRT4 NdrpClientCall3 + 0x2e2!
09:U 000007fefde521d0 OLE32 ObjectStublessClient + 0x11d!
0A:U 000007fefdd0d8a2 OLE32 ObjectStubless +的0x42!
0B:ü000007fefdd2ea07 OLE32 CObjectContext :: …
Roslyn 准备好使用 C# 10 了吗?
这是我的旧代码:
syntaxTrees.AddRange( filesToCompile.ConvertAll( filename => Parse( File.ReadAllText( filename ), filename, CSharpParseOptions.Default.WithLanguageVersion( LanguageVersion.CSharp9 ) ) ) );
Run Code Online (Sandbox Code Playgroud)
看起来更相关的部分:
CSharpParseOptions.Default.WithLanguageVersion( LanguageVersion.CSharp9 )
Run Code Online (Sandbox Code Playgroud)
语言版本好像CSharp10还没有enum?