我的Android设备连接到我的笔记本电脑,当我尝试运行时:
adb shell pm set-install-location 2
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
"Package android does not belong to 2000"
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
我该如何解决?
我有一个配置文件app.exe.config和appSettings部分有这样的:
<configuration>
<appSettings configSource="app.file.config" />
</configuration>
Run Code Online (Sandbox Code Playgroud)
app.file.config文件有这样的东西:
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="var1" value="value 1" />
<add key="var2" value="value 2" />
<add key="var3" value="value 3" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我需要在运行时编辑var1,var2和var3,我有这样的代码:
Configuration config = ConfigurationManager.OpenExeConfiguration("...path\app.exe);
config.AppSettings.SectionInformation.ConfigSource = "app.file.config";
config.AppSettings.Settings["var1"].Value = "value 11";
config.AppSettings.Settings["var2"].Value = "value 22";
config.AppSettings.Settings["var3"].Value = "value 33";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
Run Code Online (Sandbox Code Playgroud)
当我运行config.Save ....文件app.file.config有一个appSettings节点,其属性为"file".此属性具有app.file.config的值
<appSettings file="app.file.config">
<add key="var1" value="value 1" />
<add key="var2" value="value 2" />
<add key="var3" value="value 3" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
现在,如果我尝试加载配置文件,我有一个例外,消息"无法识别的属性'文件'.请注意,属性名称区分大小写." 在app.file.config中.
如果手动删除文件属性,则会正确加载配置文件.
有任何想法吗?
保存配置文件时如何避免写入文件属性.
谢谢
我有这段代码:
try
{
var files = from folder in paths
from file in Directory.EnumerateFiles(path, pattern, searchOption)
select new Foo() { folder = folder, fileName = file };
Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism }, currentFile =>
{
DoWork(currentFile);
});
}
catch (Exception ex)
{
}
Run Code Online (Sandbox Code Playgroud)
当我有异常时Directory.EnumerateFiles,我无法在这段代码中捕获此异常.调用此代码段的方法捕获到异常.
从Visual Studio,在调试模式下,Visual Studio捕获异常(例如a DirectoryNotFoundException).
我在Ubuntu 18.04上有下一个C代码:
#define ID_LEN 5
int main(int argc, char *argv[])
{
int variableNumberOfElements = 5;
char **orderedIds;
*orderedIds = (char *) malloc(variableNumberOfElements * sizeof (char*));
for (int i = 0; i < variableNumberOfElements; i++)
orderedIds[i] = (char *) malloc((ID_LEN+1) * sizeof(char));
for (int i = 0; i < variableNumberOfElements; i++)
free (orderedIds[i]);
free(*orderedIds);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我以这种方式构建此代码:
g++ -g mymain.c
Run Code Online (Sandbox Code Playgroud)
当我运行这个程序时,我收到一个"分段故障(核心转储)"错误
*orderedIds = (char *) malloc(variableNumberOfElements * sizeof (char*));
Run Code Online (Sandbox Code Playgroud)
哪个是问题?
更新:
分配内存的正确方法是:orderedIds =(char**)malloc(variableNumberOfElements*sizeof(char*));
和:free(orderedIds);
谢谢