首页 \ 问答 \ Fitnesse加载DLL的问题(Fitnesse problems loading dll)

Fitnesse加载DLL的问题(Fitnesse problems loading dll)

我在加载that.dll包含调用my work的测试类时遇到问题。

我可以用helloworld.dll做得很好但是当我把helloworld测试放在我的test.dll中时,即使我从test.dll中删除了我的work.dll引用,也无法加载

我认为她的问题是,Fitness不知道work.dll的路径,我该如何指定呢? (优先在根页面)

我得到的错误信息是:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\..\test.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'file:///C:\Projects\..\test.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at fitSharp.Machine.Engine.CurrentDomain.LoadAssembly(String assemblyPath)
   at fitSharp.Machine.Engine.ApplicationUnderTest.Assemblies.AddAssembly(String assemblyName)
   at fitSharp.Machine.Engine.ApplicationUnderTest.AddAssemblies(IEnumerable`1 assemblyNames)
   at fitnesse.fitserver.FitServer.ParseCommandLineArguments(IEnumerable`1 args)
   at fitnesse.fitserver.FitServer.Run(IList`1 CommandLineArguments)
   at fitnesse.fitserver.FitServer.Run(IList`1 commandLineArguments, Memory memory, ProgressReporter reporter)
   at fitSharp.Machine.Application.Shell.Run()
   at fitSharp.Machine.Application.Shell.Execute()
   at fitSharp.Machine.Application.Shell.Run(IList`1 commandLineArguments)

=== Pre-bind state information ===
LOG: User = kenneth
LOG: Where-ref bind. Location = C:\Projects\..\test.dll
LOG: Appbase = file:///C:/Projects/fitnesse/dotnet2/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Projects\fitnesse\dotnet2\Runner.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Projects/../test.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

有没有人有任何线索/提示。

谢谢肯尼斯


I am having trouble loading the that.dll contains my test classes that call into my work.dll.

I can do it nicely with a helloworld.dll but when I put the helloworld test in my test.dll, It cannot load, even after I remove my work.dll references from the test.dll

I think the problem her is that the path to the work.dll is not known by Fitness, how do I specify it? ( preferebly in the root page)

the error messages I get are:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\..\test.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'file:///C:\Projects\..\test.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at fitSharp.Machine.Engine.CurrentDomain.LoadAssembly(String assemblyPath)
   at fitSharp.Machine.Engine.ApplicationUnderTest.Assemblies.AddAssembly(String assemblyName)
   at fitSharp.Machine.Engine.ApplicationUnderTest.AddAssemblies(IEnumerable`1 assemblyNames)
   at fitnesse.fitserver.FitServer.ParseCommandLineArguments(IEnumerable`1 args)
   at fitnesse.fitserver.FitServer.Run(IList`1 CommandLineArguments)
   at fitnesse.fitserver.FitServer.Run(IList`1 commandLineArguments, Memory memory, ProgressReporter reporter)
   at fitSharp.Machine.Application.Shell.Run()
   at fitSharp.Machine.Application.Shell.Execute()
   at fitSharp.Machine.Application.Shell.Run(IList`1 commandLineArguments)

=== Pre-bind state information ===
LOG: User = kenneth
LOG: Where-ref bind. Location = C:\Projects\..\test.dll
LOG: Appbase = file:///C:/Projects/fitnesse/dotnet2/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Projects\fitnesse\dotnet2\Runner.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Projects/../test.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Does anyone have any clues/tips.

thanks kenneth


原文:https://stackoverflow.com/questions/17747567
更新时间:2024-01-21 12:01

最满意答案

我不知道您使用的是哪种编程语言,但我将使用PHP Laravel和AngularJS给您一个示例。

API

Route::get('/api/users', function ()
{
    $users = App\User::all();
    return $users;
});

Route::get('/api/users/admin', function ()
{
    $users = App\User::where('admin', true)->get();
    return $users;
});

面前

angular.module('app', [])
.service('api', ['$http', function ($http) {
  function getUsers() {
    return $http.get('/api/users');
  }
  function getAdminUsers() {
    return $http.get('/api/users/admin');
  }
  this.getUsers = getUsers;
  this.getAdminUsers = getAdminUsers;
}])
.controller('UserCtrl', ['$scope', 'api', function ($scope, api) {
  $scope.users = [];
  $scope.adminUsers = [];
  api.getUsers()
    .then(function success(response) {
      $scope.users = response.data;
    }, function error(response) {
    });
    api.getAdminUsers()
    .then(function success(response) {
      $scope.adminUsers = response.data;
    }, function error(response) {
    });
}]);

Sorry about the lack of details in my question. I was actually asking the question about the angular-restmod module.

Here's what I did in the end:

module.factory('CustomMethods', ['restmod', 'RMUtils', function CustomMethodsMixin(restmod, RMUtils) {
  return restmod.mixin(function() {
    this.define('Model.$customCollection', function(_url, params) {
      var original = this;
      return this.$collection(params, {
        $urlFor: function() {
          return RMUtils.joinUrl(original.$url(), _url);
        }
      });
    });
    return this;
  });
}]);

And expose all my api to it:

restmodProvider.rebase('CustomMethods')

相关问答

更多