我的ASP.Net MVC 4 Web API控制器不适用于Unity.WebApi.在同一个项目中,简单的控制器可以正常使用Unity.Mvc3.但是,当我运行从ApiController派生的Web API控制器时,我收到一条消息:
{"$ id":"1","Message":"发生错误.","ExceptionMessage":"类型'ElectricTests.Controllers.Api.DocumentsController'没有默认构造函数","ExceptionType":" System.Web.Http.Internal.TypeActivator.Create [TBase](Type instanceType)\ r \"System.Linq.Expressions.Expression.New(Type type)\ r \n的System.ArgumentException","StackTrace":" n在System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage请求,类型controllerType,Func`1和激活器)\ r \n在System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage请求,HttpControllerDescriptor controllerDescriptor,类型controllerType) )"}
我的ApiController:
public class DocumentsController : ApiController
{
private readonly IDocumentsRepository _repository;
public DocumentsController(IDocumentsRepository repository) {
_repository = repository;
}
public IEnumerable<FormattedDocument> GetFormattedDocuments()
{
return _repository.GetAllFormattedDocuments();
}
...
Run Code Online (Sandbox Code Playgroud)
Bootstrapper.cs:
public static class Bootstrapper {
public static void Initialise() {
IUnityContainer container = BuildUnityContainer();
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
}
private static IUnityContainer BuildUnityContainer() {
var container = new UnityContainer();
// register all your …Run Code Online (Sandbox Code Playgroud) 我的解决方案中有2个项目:
1).自定义操作类(CustomAction)
2).Wix安装项目(TestSetup)
CustomAction项目中有CustomAction.cs:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace CustomAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
File.Create(@"c:\installed.txt");
return ActionResult.Success;
}
}
}
Run Code Online (Sandbox Code Playgroud)
Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="TestSetup" Language="1033" Version="1.0.0.0" Manufacturer="SB2"
UpgradeCode="39d922d3-a3f5-4207-b905-124615dda25d">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="TestSetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action="CustomAction" Before="InstallFinalize" />
</InstallExecuteSequence> …Run Code Online (Sandbox Code Playgroud) 我有两个基本DOM元素和两个内部元素.
但事实并非如此.
#grey_box {
width: 200px;
height: 200px;
border: solid 1px #ccc;
background: #ddd;
position: relative;
z-index: 10;
}
#blue_box {
width: 200px;
height: 200px;
border: solid 1px #4a7497;
background: #8daac3;
position: relative;
z-index: 20;
margin-left: 80px;
margin-top: -50px;
}
#grey_inner_box {
width: 50px;
height: 50px;
background: red;
position: relative;
z-index: 200;
margin-top: 80px;
margin-left: 150px;
}
#blue_inner_box {
width: 50px;
height: 50px;
background: green;
position: relative;
z-index: 100;
margin-left: 40px;
margin-top: -40px;
}Run Code Online (Sandbox Code Playgroud)
<div id="grey_box">
<div …Run Code Online (Sandbox Code Playgroud)我在MS SQL服务器上有两个数据库(firstDB和secondDB).在firstDB中有过程[dbo].[MaintaineIndexes],在secondDB中有DatabaseEventsTrigger.
我想在运行[dbo]时禁用secondDB DatabaseEventsTrigger.[MaintaineIndexes].
所以我尝试了:
ALTER PROCEDURE [dbo].[MaintaineIndexes]
AS
BEGIN
DISABLE TRIGGER DatabaseEventsTrigger ON secondDB;
...
ENABLE TRIGGER DatabaseEventsTrigger ON secondDB;
END;
Run Code Online (Sandbox Code Playgroud)
当我正在运行过程时,我收到错误消息:"找不到对象"secondDB",因为它不存在或者您没有权限.";
好的,然后我尝试了:
DISABLE TRIGGER DatabaseEventsTrigger ON ALL SERVER;
Run Code Online (Sandbox Code Playgroud)
禁用触发器仅使用此命令:
USE [secondDB]
GO
DISABLE TRIGGER DatabaseEventsTrigger ON DATABASE;
Run Code Online (Sandbox Code Playgroud)
但我们不能在程序中使用"USE"!那么,在我的情况下如何启用/禁用触发器?