突然之间,我在解决方案中的3个项目中遇到以下错误:
Error NU1105 Unable to find project information for 'C:\code\example\src\libs\example.I18n\example.I18n.csproj'.
The project file may be invalid or missing targets required for restore.
Run Code Online (Sandbox Code Playgroud)
只有项目中的内容发生了变化才会发生一些数据库更改,但过去从未遇到过任何问题.只有我更新到Visual Studio 2017 15.5的其他内容才会导致问题?
我尝试过 - 从源代码管理中删除和重新克隆解决方案.但仍然得到错误.我的同事机器没有问题所以必须是本地的东西.
其中一个.csproj文件的示例如果有帮助:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<AssemblyName>Example.I18n</AssemblyName>
<PackageId>Example.I18n</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="MessageFormat" Version="1.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud) csproj visual-studio nuget nuget-package-restore visual-studio-2017
使用Visual Studio 2017,AspNetCore 1.1.2
突然之间,当我尝试在解决方案中发布(发布版本)任何项目时,我遇到了以下错误:
资产文件'C:\ example\obj\project.assets.json'没有'.NETFramework,Version = v4.5.2/win7-x86'的目标.确保已运行还原,并且已在项目的TargetFrameworks中包含"net452".您可能还需要在项目的RuntimeIdentifiers中包含"win7-x86".
检查了project.assets.json文件,我有:
"targets": {
".NETFramework,Version=v4.5.2": {
Run Code Online (Sandbox Code Playgroud)
和
"runtimes": {
"win7-x86": {
"#import": []
}
Run Code Online (Sandbox Code Playgroud)
在*.csproj文件中我有:
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
在项目中没有对配置进行任何更改.唯一的问题是我已经将VS2017更新到今天的最新版本,15.6.3.这会引起问题吗?
我想将文件从Azure App Service上的文件夹推送到Git存储库.
我已将本地git repo复制到服务器,我使用LibGit2Sharp提交并推送这些文件:
using (var repo = new Repository(@"D:\home\site\wwwroot\repo"))
{
// Stage the file
Commands.Stage(repo, "*");
// Create the committer's signature and commit
Signature author = new Signature("translator", "example.com", DateTime.Now);
Signature committer = author;
// Commit to the repository
Commit commit = repo.Commit($"Files updated {DateTime.Now}", author, committer);
Remote remote = repo.Network.Remotes["origin"];
var options = new PushOptions
{
CredentialsProvider = (_url, _user, _cred) =>
new UsernamePasswordCredentials
{
Username = _settings.UserName,
Password = _settings.Password
}
};
repo.Network.Push(remote, @"+refs/heads/master", options);
} …Run Code Online (Sandbox Code Playgroud) 我正在实现一个AngularJS应用程序,它将使用IdentityServer4进行授权.
我在.Net Core 2.0应用程序中有一个独立的Angular应用程序,该应用程序调用.net核心应用程序中的api控制器.如果我浏览到http://localhost:5050/.well-known/openid-configuration我正在让json返回.
我使用此示例作为我的身份验证服务的基础:
function authService() {
var config = {
authority: "http://localhost:5050",
client_id: "js",
redirect_uri: "http://localhost:5050/LocalizationAdmin/callback.html",
response_type: "id_token token",
scope: "openid profile api1",
post_logout_redirect_uri: "http://localhost:5050/LocalizationAdmin/index.html"
};
var mgr = new Oidc.UserManager(config);
mgr.getUser().then(function (user) {
if (user) {
log("User logged in", user.profile);
} else {
log("User not logged in");
}
});
var service = {
login: login,
logout: logout,
};
return service;
function login() {
mgr.signinRedirect();
}
Run Code Online (Sandbox Code Playgroud)
在callback.html我添加:
<body>
<script src="scripts/oidc-client.js"></script>
<script>
new …Run Code Online (Sandbox Code Playgroud) 在app.jsI hava中,AuthorizationInterceptor它检查用户是否已登录。当用户令牌到期时,它会遇到err条件和错误Frame window timed out(请参见下文),然后进入重定向循环。我想进行无提示登录,但我想iframe出错了。我看不到它曾经重定向到silent-callback.html-仅命中callback.html:
app.factory("AuthorizationInterceptor", ['$q', '$injector', '$rootScope', '$window', 'authService', function ($q, $injector, $rootScope, $window, authService) {
var request = function (requestSuccess) {
var currentTime = Math.floor(Date.now() / 1000);
var deferred = $q.defer();
var oidcManager = window.translation.oidcUserManager;
oidcManager.getUser().then(function (u) {
if (u) {
if (u['expires_at'] < currentTime + 10) {
oidcManager.signinSilent()
.then(function (user) {
requestSuccess.headers['Authorization'] = "Bearer " + user["access_token"];
deferred.resolve(requestSuccess);
}, function (err) {
console.log('getuser error' + err); …Run Code Online (Sandbox Code Playgroud) 我试图从MVC POST操作方法调用Web API并收到结果,但不知道如何,例如:
[HttpPost]
public ActionResult Submit(Model m)
{
// Get the posted form values and add to list using model binding
IList<string> MyList = new List<string> { m.Value1,
m.Value2, m.Value3, m.Value4};
return Redirect???? // Redirct to web APi POST
// Assume this would be a GET?
return Redirect("http://localhost:41174/api/values")
}
Run Code Online (Sandbox Code Playgroud)
我希望将上面的MyList发送到Web Api进行处理,然后将结果(int)发送回原始控制器:
// POST api/values
public int Post([FromBody]List<string> value)
{
// Process MyList
// Return int back to original MVC conroller
}
Run Code Online (Sandbox Code Playgroud)
不知道如何继续,任何帮助表示赞赏.
我有一个具有多个文本输入的表单,我不想为每个添加id,因为它们是从服务器端代码生成的 - 字段数可能不同等等.我只是希望能够禁用提交按钮,直到那里是输入到每个文本输入的文本.
我已经做到这一点,但只禁用按钮,直到文本输入到一个文本输入字段 - 我希望它保持禁用状态,直到文本输入到所有文本输入.
<script>
$(function () {
$('#button').attr('disabled', true);
$('input:text').keyup(function () {
$('#button').prop('disabled', this.value == "" ? true : false);
})
});
</script>
Run Code Online (Sandbox Code Playgroud)
我也尝试过$('input:text').each().keyup(function (){- 但是没有按钮可点击?
libgit2sharp生成文件后,我正在使用它们将文件推送到存储库。
using (var repo = new Repository(RepositoryPath))
{
// Stage the file
Commands.Stage(repo, "*");
// Create the committer's signature and commit
Signature author = new Signature("translator", "example.com", DateTime.Now);
Signature committer = author;
// Commit to the repository
Commit commit = repo.Commit($"Resx files updated {DateTime.Now}", author, committer);
Remote remote = repo.Network.Remotes["origin"];
var options = new PushOptions
{
CredentialsProvider = (_url, _user, _cred) =>
new UsernamePasswordCredentials
{
Username = _settings.GitUserName,
Password = _settings.GitPassword
}
};
repo.Network.Push(remote, @"refs/heads/master", options);
}
Run Code Online (Sandbox Code Playgroud)
这已经有一段时间了,并且没有问题地推送到存储库,但是我现在收到某些文件的以下错误消息,并且没有发生任何文件的推送。
错误消息(来自服务器日志): …
更新了 Visual Studio,现在在尝试构建项目时收到错误消息:
ENOENT: no such file or directory, scandir 'C:\code\myproj\content\node_modules\gulp-sass\node_modules\node-sass\vendor'
在 package.json 我有:"gulp-sass": "^3.1.0",
我检查了路径,果然没有vendor文件夹?但如何解决这个问题呢?
我是C#的新手并且到处寻找这个但是如果已经被问到的话就找不到答案.我试图使用for循环来比较2个列表:
IList<string> List1 = new List<string> { usr.User1, usr.User2, usr.User3, usr.User4 };
IList<string> List2 = new List<string>{ "Tim", "Bob", "Brian", "Paul" };
Run Code Online (Sandbox Code Playgroud)
基本上我希望只有4个可能的匹配,所以只有这些可能的匹配应该计算:
usr.User1 == "Tim", // e.g. User1 has to be Tim etc.
usr.User2 == "Bob",
usr.User3 == "Brian",
usr.User4 == "Paul"
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望返回一个值为0-4的int,所以如果上面的所有匹配都成功,那么它将返回4,如果没有匹配成功则返回0等.
我试过了:
int score = 0;
for (int i = 0; i <= List2.Count; i++)
{
if (List1[i] == List2[i])
{
score++;
}
}
Run Code Online (Sandbox Code Playgroud)
但目前正在获取IndexOutOfRangeException.非常感谢.
c# ×3
angularjs ×2
git ×2
javascript ×2
libgit2sharp ×2
asp.net-core ×1
asp.net-mvc ×1
azure ×1
bitbucket ×1
csproj ×1
forms ×1
gulp ×1
gulp-sass ×1
jquery ×1
libgit2 ×1
nuget ×1
redirect ×1