I am getting error while executing below command in powershell.
[Reflection.Assembly]::LoadFile("C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
This is the error.
Exception calling "LoadFile" with "1" argument(s): " is not a valid Win32 application. (Exception from HRESULT: 0x80070
0C1)"
At line:1 char:32
+ [Reflection.Assembly]::LoadFile <<<< ("C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Can anybody advise me what am i doing wrong?
I checked this path (
C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll
) and it is correct.
Update:
Powershell version is 2.
And i tried these as well
Add-Type -AssemblyName "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
Add-Type "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
But no luck.
In that case, most probably you are running PowerShell version 2.0 with .NET Framework version 4.0 which is incompatible. Try using a compatible .NET Framework version. To check
Powershell version run the command
$PSVersionTable.psversion
To check .NET framework version installed run below command and check the 2nd line 3rd column data
gci "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP"
EDIT:
Few more suggestions:
Try using LoadFrom() instead like
[Reflection.Assembly]::Assembly.LoadFrom("c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll");
(OR) Try using Add-Type instead like
Add-Type -AssemblyName "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
Also, make sure that you are not trying load 32-bit Oracle.DataAccess.dll from 64-bit Windows Powershell. I mean they both should be compaitible.
Related
I'm trying to package SCOM Console 2016 using Thinapp 5.2. The customer wants to use the PowerShell part of SCOM as well. But whenever i start SCOM Shell, it gives me a bunch of errors telling me that it can't find certain .dll files and more.
I have already tried installing it on a VM before but it gives me the same error messages, so Thinapp is not causing the errors.
Does anyone know where i should look?
Import-Module : Cannot load Windows PowerShell snap-in C:\Program Files (x86)\System Center Operations Manager 2016\Powershell\OperationsManager\OM10.CoreCommands\Microsoft.EnterpriseManagement.Core.Cmdlets.dll because of the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Loader Exceptions:
Could not load file or assembly Microsoft.EnterpriseManagement.Core, Version=7.0.5000.
, Culture=neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies.
The system cannot find the file specified.
At C:\Program Files (x86)\System Center Operations Manager 2016\Powershell\OperationsManager\OperationsManager.psm1:1261 char:14
+ Import-Module <<<< $psScriptRoot\OM10.CoreCommands\OM10.CoreCommands.psd1
+ CategoryInfo : ResourceUnavailable: (:) [Import-Module], PSSnapInException
+ FullyQualifiedErrorId : PSSnapInLoadFailure,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : Could not load file or assembly file:///C:\Program Files (x86)\Systemcenter Operations Manager 2016\Powershell\OperationsManager\OM10.Commands\Microsoft.SystemCenter.OperationsManagerV10.Commands.dll or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded
At C:\Program Files (x86)\System Center Operations Manager 2016\Powershell\OperationsManager\OperationsManager.psm1:1262 char:14
+ Import-Module <<<< $psScriptRoot\OM10.Commands\OM10.Commands.psd1
+ CategoryInfo : NotSpecified: (:) [Import-Module], BadImageFormatException
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand
Add-Type : Could not load file or assembly file:///C:\Program Files (x86)\System Center Operations Manager 2016\Console\Microsoft.Mom.Common.dll or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded
At C:\Program Files (x86)\System Center Operations Manager 2016\Powershell\OperationsManager\OperationsManager.psm1:1311 char:15
+ Add-Type <<<< -Path $consoleMomCommon
+ CategoryInfo : NotSpecified: (:) [Add-Type], BadImageFormatException
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.AddTypeCommand
Problem solved, it turned out we were using an old version of Windows Management Framework. After updating to version 5.1 all the errors were gone. I installed this update: KB3191566
Like pik which provides the facility to switch between ruby versions on the fly from command prompt, is there any tool which provides the same kind of behavior for gradle, so that i can switch to gradle version I'm using based on need.
I googled it, but couldn't find proper solution. So posting here.
Below error I'm getting when use sdkman windows version:
PS C:\Users\user> Import-Module posh-gvm
This command is not available in offline mode.
At C:\Users\user\Documents\WindowsPowerShell\Modules\posh-gvm\Utils.ps1:294 char:14
+ throw <<<< 'This command is not available in offline mode.'
+ CategoryInfo : OperationStopped: (This command is...n offline mode.:String) [], RuntimeException
+ FullyQualifiedErrorId : This command is not available in offline mode.
Import-Module : The specified module 'posh-gvm' was not loaded because no valid module file was found in any module dir
ectory.
At line:1 char:14
+ Import-Module <<<< posh-gvm
+ CategoryInfo : ResourceUnavailable: (posh-gvm:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Yes, there's such tool. It's called sdkman. You can easily switch between versions of gradle, groovy and other available frameworks, languages.
This is my code to connect to an Oracle database:
[Reflection.Assembly]::LoadFile("E:\oracle\product\11.2.0\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
$constr = "User Id=system;Password=password;Data Source=SERVER\INST"
$conn= New-Object Oracle.DataAccess.Client.OracleConnection($constr)
First line is working fine. I can see the assembly is loading and GAC is true.
Up to the second line there is no error.
But when it reaches the 3rd line, I am getting this error:
New-Object : Exception calling ".ctor" with "1" argument(s): "The type initializer for 'Oracle.DataAccess.Client.Oracle Connection' threw an exception.
$conn= New-Object <<<< Oracle.DataAccess.Client.OracleConnection($constr)
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
"
Can anybody advise me on this.
Powershell version is 2.
Update
PS I:\> [Reflection.Assembly]::LoadFile("E:\oracle\product\11.2.0\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
GAC Version Location
--- ------- --------
True v2.0.50727 C:\Windows\assembly\GAC_64\Oracle.DataAccess\2.112.3.0__89b483f429c47342\Oracle.DataAccess.dll
Oracle.DataAccess.dll is architecture specific. That means that you have to make sure the PowerShell process and the Oracle.DataAccess.dll assembly have the same bits (32 or 64).
May I suggest you to use the platform-independent Oracle managed driver? It works a lot better than the Oracle client specific Oracle.DataAccess.
Also see my answer here.
I have just started using Visual Studio 2013 with EF6 and I have created a demo application with MVC 4. I tried to scaffold a controller but i keep getting an error. I have installed MVCScaffolding from the Package Manager Console and everything installed correctly including T4Scaffolding, T4Scaffolding.Core... however I keep getting this error. Please help me out
Invoke-Scaffolder : A positional parameter cannot be found that accepts argument 'Student'.
At line:1 char:1
+ Scaffold Controller Student -Repository
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
Please tell me what I am doing wrong. Thanks A lot
I had a similar problem. Try with MVC 5.
Thank you for the suggestions. I solved this by using this command instead. Worked like a charm.
Install-Package MvcScaffolding -Version 1.0.8-vs2013 -Pre
I got it from this another question
I am trying to debug T4Scaffolding.Core Nuget package from outside Visual Studio 2012.
I am using Powershell ISE with Powershell 3.0 installed and run under CLRVersion 4.0.30319.
I first import several Nuget related items:
- Profile.ps1
- nuget.psm1
- NuGet.Cmdlets.dll
I am also setting the current location to set-location "\ClassLibrary1\"
and obtained the only DTE instance currently running (I previously opened MySolution in VS 2012 that has a class library and an asp.net MVC 4 application in it)
$dte = [runtime.interopservices.marshal]::GetActiveObject("visualstudio.dte")
I skipped importing Get-Project cmdlet from NuGet.Cmdlets.dll binary module, so I can create my own cmdlets: Get-Project
that gets my MVC project this way:
$project = $dte.Solution.Projects.Item("MvcApplication1\MvcApplication1.csproj")
I am able to step into init.ps1:
\packages\T4Scaffolding.Core.1.0.0\tools\init.ps1
but the code fails when executing:
Set-DefaultScaffolder -Name CustomTemplate -Scaffolder T4Scaffolding.CustomTemplate -SolutionWide -DoNotOverwriteExistingSetting
Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At line:1 char:1
+ Set-DefaultScaffolder -Name CustomTemplate -Scaffolder T4Scaffolding.CustomTempl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
+ FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
I also tried pointing to my $project name (omitting -SolutionWide) with the same results.:
Set-DefaultScaffolder -Name CustomTemplate -Scaffolder T4Scaffolding.CustomTemplate -Project ($project).Name -DoNotOverwriteExistingSetting
I could observe that EnvDTE.dll is loaded into Powershell ISE environment by using:
[System.Threading.Thread]::GetDomain().GetAssemblies()
Hopefully someone will be interested in achieving the same goal (stepping line by line through init.ps1 and install.ps1 of a Nuget package outside Visual Studio).
Thanks,
Rad
Stack Overflow: question I used as a starting point
I got same error message:
Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
but in different scenario. I was using scaffold in VS2015, installed T4Scaffolding.Core. Then I found the solution from this link
By installing Windows Management Framework 4.0 the error is gone and my scaffold works again.
Hopes this can help.