WatiN .NET 4.0 and the loadFromRemoteSources Element in App.config

I am using .NET 4.0 with IronRuby to invoke some methods on WatiN
framework
2.0.10.928.

I keep getting the following error when loading the WatiN assemblies:

C:\Projects\IronRubyDemo\IronRubyDemoSolution\BusinessObjects>ir -S spec
testacc
ountbalanceUI.rb
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:30:in
require': A n attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so thi s load may be dangerous. If this load is not intended to sandbox the assembly, p lease enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlin k/?LinkId=155569 for more information. (LoadError) from C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:30:inrequire’

So, I went to the App.config file of my project and added the following
lines:

<?xml version="1.0" encoding="utf-8" ?>

I tried running it again and encountered the same problem. Any ideas!

Your app is not the thing trying to load that assembly, IronRuby is. So,
you’ll need to add that to IronRuby’s app.config.

That said, why are you trying to load an assembly from a network
location in
your tests? That is, IMO bad testing practice.


Will G.
http://hotgazpacho.org/

Will G. wrote:

Your app is not the thing trying to load that assembly, IronRuby is. So,
you’ll need to add that to IronRuby’s app.config.

That said, why are you trying to load an assembly from a network
location in
your tests? That is, IMO bad testing practice.


Will G.
http://hotgazpacho.org/

I am not sure what you mean by IronRuby app.config. Where is IronRuby
app.config located? I guess it should be in the installed folder of
IronRuby.

Also, I am just loading an assembly from my local machine.

Thanks for the help! I edited the IronRuby configuration file and now
the error has disappeared.

wherever you installed ironruby. it’s called ir.exe.config
for me in C:\ironruby\bin

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.

I created a new project in Visual Studio 2008 and tried running the same
code and it worked without any problems. It did not gave me load error
for the Interop.SHDocVw.dll.

Looks like there are some issues with WatiN when using it on .NET 4.0
framework.

Actually facing the same problem on VS 2008.

Got the first problem solved by editing the configuration file. Now,
facing problem loading the Interop.SHDocVw assembly. Here is the
complete code:

require ‘rubygems’
require ‘spec’

require File.dirname(FILE) + ‘/bin/Debug/BusinessObjects.dll’
require File.dirname(FILE) + ‘/bin/Debug/WatiN.Core.dll’
require File.dirname(FILE) + ‘/bin/Debug/Microsoft.mshtml.dll’
require File.dirname(FILE) + ‘/bin/Debug/Interop.SHDocVw.dll’

include BusinessObjects
include WatiN

describe Account, “when something happens” do

before do

IE = WatiN::Core::IE
@ie = IE.new

end

it “should do something” do

end

end

And here is the error:

C:\Projects\IronRubyDemo\IronRubyDemoSolution\BusinessObjects>ir -S spec
testacc
ountbalanceUI.rb
F

Errno::ENOENT in ‘BusinessObjects::Account when something happens should
do some
thing’
Could not load file or assembly ‘Interop.SHDocVw, Version=1.1.0.0,
Culture=neutr
al, PublicKeyToken=db7cfd3acb5ad44e’ or one of its dependencies. The
system cann
ot find the file specified.
./testaccountbalanceUI.rb:18:

Finished in 0.148009 seconds

1 example, 1 failure

instead of requiring the files with path. maybe try to set the load path

$:.unshift( File.dirname(FILE) + “/bin/Debug”)
require ‘BusinessObjects.dll’
require ‘WatiN.Core.dll’
require ‘Microsoft.mshtml.dll’
require ‘Interop.SHDocVw.dll’

I also think that the last 2 are redundant… they should get picked up
automatically by Watin.Core isn’t it

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Web: http://whiterabbitconsulting.eu - http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Microsoft IronRuby/C# MVP

Ivan Porto C. wrote:

instead of requiring the files with path. maybe try to set the load path

$:.unshift( File.dirname(FILE) + “/bin/Debug”)
require ‘BusinessObjects.dll’
require ‘WatiN.Core.dll’
require ‘Microsoft.mshtml.dll’
require ‘Interop.SHDocVw.dll’

I also think that the last 2 are redundant… they should get picked up
automatically by Watin.Core isn’t it

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Web: http://whiterabbitconsulting.eu - http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Microsoft IronRuby/C# MVP

You are right! It should be loaded automatically but for some reason it
is not. Here is my IronRuby code:

require ‘rubygems’
require ‘spec’

require File.dirname(FILE) + ‘/bin/Debug/BusinessObjects.dll’
require File.dirname(FILE) + ‘/bin/Debug/WatiN.Core.dll’

include BusinessObjects
include WatiN

describe Account, “when something happens” do

before do

IE = WatiN::Core::IE

i = IE.new()

end

it “should do something” do

end

end

And here is the error I get:

C:\Projects\TestingIronRuby\BusinessObjects\BusinessObjects>ir -S spec
testaccou
ntbalanceUI.rb
F

Errno::ENOENT in ‘BusinessObjects::Account when something happens should
do some
thing’
Could not load file or assembly ‘Interop.SHDocVw, Version=1.1.0.0,
Culture=neutr
al, PublicKeyToken=db7cfd3acb5ad44e’ or one of its dependencies. The
system cann
ot find the file specified.
./testaccountbalanceUI.rb:19:

Finished in 0.150009 seconds

1 example, 1 failure

The load path basically determines where ir.exe looks for assemblies and
files to load.

if you do

$LOAD_PATH.unshift(File.dirname(FILE) +"/bin/Debug")
and then require Watin.Core.dll the CLR knows where to look for your
DLL’s
including the referenced assemblies

You might have gotten a correct result by including your assemblies in
the
inverted order too

So either you do :

$LOAD_PATH.unshift(File.dirname(FILE) +"/bin/Debug")
require ‘BusinessObjects.dll’
require ‘WatiN.Core.dll’

or this might work too:

require File.dirname(FILE) +"/bin/Debug/Interop.SHDocVw.dll"
require File.dirname(FILE) +"/bin/Debug/Microsoft.mshtml.dll"
require File.dirname(FILE) +"/bin/Debug/BusinessObjects.dll"
require File.dirname(FILE) +"/bin/Debug/WatiN.Core.dll"


Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.

Ivan Porto C. wrote:

instead of requiring the files with path. maybe try to set the load path

$:.unshift( File.dirname(FILE) + “/bin/Debug”)
require ‘BusinessObjects.dll’
require ‘WatiN.Core.dll’
require ‘Microsoft.mshtml.dll’
require ‘Interop.SHDocVw.dll’

I also think that the last 2 are redundant… they should get picked up
automatically by Watin.Core isn’t it

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Web: http://whiterabbitconsulting.eu - http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Microsoft IronRuby/C# MVP

Hi Ivan,

I tried it without the path and it worked instantly. Why is it
different? I mean why does it not work when I include the path and why
does it work when I set the load path?