小编Bry*_*yan的帖子

构建错误,该项目引用了NuGet

当我尝试构建我的解决方案时,我收到以下错误消息:

严重级代码说明项目文件行抑制状态错误此项目引用此计算机上缺少的NuGet程序包.使用NuGet Package Restore下载它们.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105.丢失的文件是..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props.MusicKarma C:\ Users\Bryan\Documents\Visual Studio 2015\Projects\MusicKarma\MusicKarma.csproj 268

当我查看我的包文件夹时,我可以找到名为Microsoft.Net.Compilers.props的文件

我曾尝试使用Nuget Restore,但它一直说我有所有的包.谁可以帮助我?

当我将这个项目从TFS带到我的一台计算机时会发生这种情况.

.net visual-studio nuget nuget-package-restore

31
推荐指数
5
解决办法
10万
查看次数

AspNetUserLogins表标识

什么是AspNetUserLogins?是否存储用户的登录信息?如何用该数据更新此表?

c# asp.net-mvc entity-framework asp.net-identity

28
推荐指数
1
解决办法
1万
查看次数

无法从程序集加载"Microsoft.CodeAnalysis.BuildTasks.Csc"任务

我有一个TFS在线项目.当我试图构建项目时,我收到以下错误:

严重级代码说明项目文件行错误无法从程序集C:\ Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0加载"Microsoft.CodeAnalysis.BuildTasks.Csc"任务. 0 \建.. \工具\ Microsoft.Build.Tasks.CodeAnalysis.dll.无法加载文件或程序集'file:/// C:\ Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll '或其中一个依赖项.找不到该文件.确认声明是否正确,程序集及其所有依赖项是否可用,以及该任务是否包含实现Microsoft.Build.Framework.ITask的公共类.ContosoUniversity

这与Azure有什么关系不支持ASP.NET 4.6吗?

c# visual-studio azure-devops azure-pipelines

21
推荐指数
4
解决办法
3万
查看次数

与dapper的通用存储库

我试图用dapper构建一个通用的存储库.但是,我在实现CRUD操作时遇到了一些困难.

这是存储库中的一些代码:

 public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class
{
    internal IDbConnection Connection
    {
        get
        {
            return new SqlConnection(ConfigurationManager.ConnectionStrings["SoundyDB"].ConnectionString);
        }
    }

    public GenericRepository(string tableName)
    {
        _tableName = tableName;
    }

    public void Delete(TEntity entity)
    {
        using (IDbConnection cn = Connection)
        {

            cn.Open();
            cn.Execute("DELETE FROM " + _tableName + " WHERE Id=@ID", new { ID = entity.Id });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如您所见,我的delete-method将TEntity作为参数,它是类类的参数.

我从我的UserRepository调用我的Delete方法,如下所示:

public class UserRepository : GenericRepository<User>, IUserRepository
{
    private readonly IConnectionFactory _connectionFactory;

    public UserRepository(IConnectionFactory connectionFactory) : base("User")
    { …
Run Code Online (Sandbox Code Playgroud)

c# sql asp.net-mvc dapper

9
推荐指数
2
解决办法
7788
查看次数

ASP.NET MVC中的路由,显示URL中的用户名

我试图建立一个路线,所以我可以在URL中显示用户名,如下所示:

HTTP:// localhost1234 /约翰·

这是我的routeconfig:

 routes.MapRoute(
                name: "users", // Route name
                url: "{username}", // URL with parameters
                defaults: new { controller = "Home", action = "Index", username = "" } // Parameter defaults
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
Run Code Online (Sandbox Code Playgroud)

这是我的HomeController:

 public ActionResult Index(string username = "Test")
 {
   return View();
  }
Run Code Online (Sandbox Code Playgroud)

首先,URL未更改.当我username = "Test"在route-config中设置时,URL不会更改.

其次,我无法导航到我的其他控制器.如果我将URL更改为http:// localhost123/Welcome,则不会发生任何事情.它应该将我重定向到一个新页面.

我在这做错了什么?

如果我更改路由的顺序,我可以导航到其他页面,但用户名不显示在URL中.

我用谷歌搜索过,关于这个问题的所有答案都说我应该使用像上面那样的路线.

c# asp.net-mvc routes

7
推荐指数
1
解决办法
4405
查看次数

无法制作新的newRequestQueue In Volley,android

我有一个片段,我尝试newRequestQueue用Volley API 实例化一个新的.

我尝试像这样实例化它:

RequestQueue queue = Volley.newRequestQueue(this);
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试创建请求时,我收到以下错误:

newRequestQueue In Volley cannot be applied to annonymous android.view.View.OnClickListener
Run Code Online (Sandbox Code Playgroud)

这是我的片段类:

public class LoginFragment extends Fragment {
    private FacebookLogin fLogin;
    private Profile profile;
    private CallbackManager mCallbackManager; //Used in activity result below. Gets a value when u hit the button
    private static final String TAG = "Event";
    private static String url_create_user = "127.0.0.1/create_row.php";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fLogin = new FacebookLogin(getActivity().getApplicationContext());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup …
Run Code Online (Sandbox Code Playgroud)

java android http httprequest android-volley

6
推荐指数
1
解决办法
9179
查看次数

使用POST获取数据

目前,当我想要获取数据时,我对 Web API 使用 POST 请求,而不是 GET 请求,因为我发送的参数超出了 URL 限制。

但是,当您想要获取数据时使用 POST 是不好的做法。

当您的参数超出 URL 限制并且必须使用 POST 而不是 GET 时,正确的方法是什么?

api rest asp.net-web-api

6
推荐指数
0
解决办法
3883
查看次数

构建:重复标识符'原型'

当我尝试构建我的应用程序时,出现以下错误:

1>node_modules\angular2\typings\browser.d.ts(6,14): error TS2300: Build: Duplicate identifier 'PromiseConstructor'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(22,5): error TS2300: Build: Duplicate identifier 'done'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(23,5): error TS2300: Build: Duplicate identifier 'value'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(46,5): error TS2300: Build: Duplicate identifier 'size'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(52,5): error TS2300: Build: Duplicate identifier 'prototype'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(66,5): error TS2300: Build: Duplicate identifier 'size'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(72,5): error TS2300: Build: Duplicate identifier 'prototype'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(88,5): error TS2300: Build: Duplicate identifier 'prototype'.
1>node_modules\angular2\typings\es6-collections\es6-collections.d.ts(103,5): error TS2300: Build: Duplicate identifier 'prototype'.
1>node_modules\angular2\typings\es6-promise\es6-promise.d.ts(11,15): error TS2300: Build: Duplicate identifier 'Promise'.
1>node_modules\angular2\typings\es6-promise\es6-promise.d.ts(42,16): error TS2300: Build: Duplicate identifier 'Promise'.
Run Code Online (Sandbox Code Playgroud)

我不明白为什么.这是我的tsconfig:

{ …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular

5
推荐指数
1
解决办法
600
查看次数

将列表保存到数据库实体框架

我有以下代码:

 internal static bool SaveUOSChangeLog(List<Contracts.DataContracts.UOSChangeLog> values, string user)
    {
        try
        {
            using(var ctx = new StradaDataReviewContext2())
            {
                values.ForEach(u => { u.Username = user; u.Changed = DateTime.Now; });
                var test = ctx.UOSChangeLog.Add(values);
                ctx.SaveChanges();
                return true;
            }
        }
Run Code Online (Sandbox Code Playgroud)

我要做的是保存values到数据库。但是,我收到以下错误消息:

在此处输入图片说明

这是我的Contracts.DataContracts.UOSChangeLog:

   public int? Id { get; set; }
        public int Accident_nr { get; set; }
        public int Refnr { get; set; }
        public int Action { get; set; }
        public string Old_data { get; set; }
        public string New_data { get; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc entity-framework

5
推荐指数
2
解决办法
2万
查看次数

在C#中使用MachineKey进行加密和解密

我正在尝试使用MachineKey加密和解密ID。

这是我的调用加密和解密功能的代码:

 var encryptedId = Encryption.Protect(profileId.ToString(), UserId);
 var decryptedId = Encryption.UnProtect(encryptedId, UserId);
Run Code Online (Sandbox Code Playgroud)

功能如下:

public static string Protect(string text, string purpose)
{
    if(string.IsNullOrEmpty(text))
    {
        return string.Empty;
    }

    byte[] stream = Encoding.Unicode.GetBytes(text);
    byte[] encodedValues = MachineKey.Protect(stream, purpose);
    return HttpServerUtility.UrlTokenEncode(encodedValues);
}

public static string UnProtect(string text, string purpose)
{
    if(string.IsNullOrEmpty(text))
    {
        return string.Empty;
    }

    byte[] stream = HttpServerUtility.UrlTokenDecode(text);
    byte[] decodedValues = MachineKey.Unprotect(stream, purpose);
    return Encoding.UTF8.GetString(decodedValues);
}
Run Code Online (Sandbox Code Playgroud)

Protect方法的输入为15。这将导致EncryptedId变量包含以下字符串:6wOttbtJoVBV7PxhVWXGz4AQVYcuyHvTyJhAoPu4Okd2aKhhCGbKlK_T4q3GgirotfOZYZXke0pMdgwSmC5vxg2

为了对此进行加密,我将此字符串作为参数发送给该UnProtect方法。解密的结果应为15,但改为:1\05\0

我不明白为什么。我试图在此函数中仅使用整数,但是我仍然遇到相同的问题。解密的输出不同。

c# asp.net machinekey

5
推荐指数
1
解决办法
2729
查看次数