Using Ikvm.dll's trying to do xmldocode.readobject() , but it throw indexoutofboundarray in web application and Console it works fine .net fram4.5 - ikvm

`<?xml version="1.0" encoding="UTF-8"?><java version="1.6.0" class="java.beans.XMLDecoder"><object class="cli.class.MyClass.WSRequest"><void method="set_idescription"><string>accountChangePswdProcessDesc</string></void><void method="set_iprocessState"><string>R</string></void><void method="set_iprocessStateString"><string>Running</string></void></object></java> in Dotnet framework 4.5
This the java xml fomat which, we need to decode using IKVM,obj = (TDotNetType)decoder.readObject();
Using IKVM Version 7.4.5.x and tried in above versions.
It works fine and can resolve the class name in Console application(Windows application). But while using the same code over the Web application it throw "Indexoutofboundarray".
stuck as it is something unexpected happing, tried different ver of dll's of ikvm in for .net 4.5 `

Related

Unable to update database to match the current model. Failing only on self hosting project

The following code:
Database.SetInitializer
(new MigrateDatabaseToLatestVersion<Db, Migrations.Configuration>(true));
using (var C = new Db())
{
Console.WriteLine(C.Usuarios.Count());
}
Works on a console test project but on the other console with self-hosting it fails with the Unable to update database to match the current model... migration error
Obviously the migrations are up to date since the other project runs fine and they both do the same configuration since the database model and the migration configuration are on a separated library
I tracked down the problem to the Newtonsoft.Json library.
The package Microsoft.AspNet.WebApi.Client depends on the version 6.0.4 of this library which seems to have conflicts with Entity Framework.
Just upgrading the Newtonsoft.Json with Install-Package Newtonsoft.Json solves the problem

ASP.net app crashes - Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop'

I want to build a Google BigQuery C# ASP.net application using OAuth2 and the .Net 4.5 framework. I ran these NuGet installs
Install-Package Google.Apis.Bigquery.v2 -Pre
Install-Package Google.Apis.Authentication.OAuth2 -Version 1.2.4696.27634
Install-Package Google.Apis -Pre
Install-Package Google.Apis.Auth -Pre
and I placed the relevant "usings" in code-behind file "default.aspx.cs":
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Bigquery.v2;
using Google.Apis.Bigquery.v2.Data;
namespace BigQueryDemoApp
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
UserCredential credential;
FileStream stream;
using (stream = new FileStream(
Server.MapPath("~/client_secrets.json"),
FileMode.Open, FileAccess.Read)
)
{
GoogleWebAuthorizationBroker.Folder =
"Tasks.Auth.Store";
credential = GoogleWebAuthorizationBroker.
AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { BigqueryService.Scope.Bigquery },
"user", CancellationToken.None).Result;
}
// Initialize the service.
var Service = new BigqueryService(
new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "BigQueryDemo"
}
);
}
}
}
I set this specific page as the project start page. I picked "Installed application" when I built the Client ID file at the Google console
APIS & auth -> Credentials -> CREATE NEW CLIENT ID
and I made sure I added this file (client_secrets.json) with the solution explorer in VS2013. In the code-behind, I made sure that I correctly mapped to the client_secrets file with Server.MapPath. For the credential machinery, I used this code
<https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2>
as the starting point. When I run the app, it returns a browser error page that starts with
Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
and crashes at the "credential =" line. I tried to add in some images of the actual ASP.net crashed browser page showing the Assembly Load Trace / Stack Trace / etc. but it looks like I don't have the account rights for this. When I set a breakpoint at the "credential =" line and then run the app through
DEBUG -> Start Debugging
in VS2013, the page stops at the "credential =" line and a file picker opens, looking for file
"GoogleClientSecrets.cs"
from directory
"c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis.Auth\OAuth2\GoogleClientSecrets.cs"
which is nowhere on the drive. Using the Assembly Load Trace in the generated ASP.net error page, I tried digging around through the suggested configuration files but nothing worked. More generally, I tried looking for this issue in StackOverflow and while I did find some mention of it, none of that material helped.
Because the error is based on the fact that the latest version of Microsoft.Bcl.Async doesn't work in .NET 4.5, you can try to do the following:
Open your Package Manager Console, and run the following commands:
1) Uninstall-Package Microsoft.Bcl.Async -Force
2) Install-Package Microsoft.Bcl.Async -Version 1.0.16
It works in a sample I'm currently writing. Please let me know if it works for you.
UPDATE (March 21st):
You can update the package (new version 1.0.166-beta is available - https://www.nuget.org/packages/Microsoft.Bcl.Async/1.0.166-beta).
I tested it on VS2013 with .NET 4.5 framework and it works.
They released a new version of -Package Microsoft.Bcl.Async.
If somebody has this issue, please install the "latest" version instead of 1.0.16.
I hope it works for you.
I already encountered this error before. It looks like the Bcl.Async package contains a reference to Microsoft.Threading.Tasks.Extensions.Desktop when you run a .NET 4.0 applications but somehow it is missing in .NET 4.5 application.
My advice for you (until I'll figure our with the owner of Microsoft.Bcl.Async why it happens) is to copy Microsoft.Threading.Tasks.Extensions.Desktop from packages\Microsoft.Bcl.Async.1.0.165\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll to your BIN folder. It should solve this issue.
UPDATE (March 17th):
Consider adding the following Post-build event to your project:
copy /Y "$(SolutionDir)packages\Microsoft.Bcl.Async.1.0.16\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll" "$(TargetDir)Microsoft.Threading.Tasks.Extensions.Desktop.dll"
Unfortunately, there isn't a solution for this problem yet from the owners of the Bcl.Async package.
This approach did not fix the issue - I got the same runtime error. But after a rebuild, I noticed that the VS2013 compiler showed this warning, which I formatted a little for the SO editor
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning
MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual
Studio, double-click this warning (or select it and press Enter) to fix the conflicts;
otherwise, add the following binding redirects to the "runtime" node in the application
configuration file:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Threading.Tasks.Extensions.Desktop" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-1.0.165.0" newVersion="1.0.165.0" />
</dependentAssembly>
</assemblyBinding>
so I dropped the suggested block in the app web.config file. Then the app decided to work. I have no idea why it works now, but I get the impression that the XML block and / or the reference fix you mentioned somehow touched the Microsoft.Threading.Tasks.Extensions.Desktop DLL, or some low-level machinery inside .Net, or both. Or neither, for all I know. Anyway, thanks for your help. I only wish I had a better understanding of the internal machinery.

How to check whether ASP.NET 4.0 registered on IIS 7.5

Is there any reliable way how to check whether ASP.NET 4.0 registered on IIS 7.5 programmatically? I need to test it in the installer as prerequisite, before ASP.NET application installation start.
If ASP.NET 4.0 not registered on the IIS, later during the installation just installed application cannot be run and returns 500 internal server error (and it is too late to solve the problem). Instead, I want to show some warning (and hint how to solve the issue) before any installation steps started. But no reliable solution found yet.
AFAIK, registry entries reading sometimes may not work correctly. So now, I run aspnet_regiis.exe -lv to list versions (as suggested here) and parse the output. But even if .NET not registered correctly my test (falsely) succeeds, because the output is (contains version 4.0):
2.0.50727.0 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll
4.0.30319.0 C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
(Win7 32bit)
Running aspnet_regiis.exe -ir can repair it in this case.
It's similar issue as this question, but I need test it programmatically.
Do you have any ideas or experiences?
Using your own answer as a basis, this can also be done using the command line (with elevation):
%WINDIR%\System32\inetsrv\appcmd.exe list apppool /managedRuntimeVersion:v4.0
If anything is returned, ASP.NET 4.0 is registered.
The issue with this approach is that it seems to be possible to create 4.0 application pools manually even if the filter is not installed, and then this method would not work.
EDIT:
I have ended up running these three checks:
aspnet_regiis.exe -lv (should return a line containing "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll")
appcmd.exe list apppool /managedRuntimeVersion:v4.0 (should return a line containing "MgdVersion:v4.0")
appcmd.exe list config -section:system.webServer/isapiFilters (should return a line containing "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll")
Note that I only care about 32bit versions.
If all three checks pass, it can be concluded that ASP.NET 4.0 is registered. Still not 100% false positive-proof though.
This is an old question, but I'm posting an answer because your question is one of the top results on google, and it's unanswered.
The registry key you are looking for is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0. If that key is present, then .Net 4 has been installed and is registered in IIS.
If you just want to check if .Net 4 is installed, you can check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full.
In Powershell it could be done like this:
# load the IIS-Commandlets
Import-Module WebAdministration
# get the isapi filters currently loaded
Get-WebConfigurationProperty -Filter "/system.webServer/isapiFilters/filter" -name *
An output could look like this:
name : ASP.Net_4.0_32bit<br/>
path : %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll<br/>
enabled : True<br/>
enableCache : True<br/>
preCondition : runtimeVersionv4.0,bitness32<br/>
ItemXPath : /system.webServer/isapiFilters/filter[#name='ASP.Net_4.0_32bit']<br/>
Attributes : {name, path, enabled, enableCache...}<br/>
ChildElements : {}<br/>
ElementTagName : filter<br/>
Methods :<br/>
Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema<br/>
name : ASP.Net_4.0_64bit<br/>
path ........
Based on that we could write this code to check and install .NET 4 if needed:
$DotNet4Missing = $true
# lets make sure we got .net 4 correctly setup
$isapiFilters = Get-WebConfigurationProperty -Filter "/system.webServer/isapiFilters/filter" -name *
"/system.webServer/isapiFilters/filter count: {0}" -f $isapiFilters.Count
foreach ($filter in $isapiFilters)
{
"filter.name: {0}" -f $filter.name
if ($filter.name -eq "ASP.Net_4.0_64bit")
{
"-> Found .NET 4 - GREAT!"
$DotNet4Missing = $false
}
}
if ($DotNet4Missing)
{
"Missing .NET 4 IIS integration - running aspnet_regiis.exe"
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = "-iru"
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
"aspnet_regiis.exe stdout: {0}" -f $stdout
"aspnet_regiis.exe stderr: {0}" -f $stderr
"aspnet_regiis.exe ExitCode: {0}" -f $p.ExitCode
}
Summary: The problem described above occurs on non-server operating system (Win7). The .NET 4.0 is not registered on the IIS even if you install IIS before .NET 4.0 (and so .NET should be registered on IIS correctly). This causes unexpected problems during any ASP.NET application installation -- until aspnet_regiis.exe -ir is ran from the commandline. There is no problem with Win 2008 (i.e. when IIS installed before .NET 4.0 then .NET is registered correctly on IIS and everything works as expected).
So finally my colleague told me what possibly could be solution of the problem. I've verified that following solution works fine (also on Win7). ServerManager from Microsoft.Web.Administration namespace can be employed easily:
public static bool IsAspNetRegistered()
{
using (var mgr = new ServerManager())
{
return mgr.ApplicationPools.Any(pool => pool.ManagedRuntimeVersion == "v4.0");
}
}
In case of successful .NET registration on IIS, there is at least one application pool which runtime version is set to "v4.0" so this fact was used for the check.
Of course, if anybody deletes all application pools, this method can work incorrectly. But this is bit pathological situation I don't care. The main issue is to prevent that although everything is done according our installation recommendations, still not possible to install the application on the machine.

How can I ignore optional parameter error on MSBuild 3.5

I am using Visual Studio 2010.
I've donwloaded an updated class (i.e. UpdatedClass.cs) which has a method with optional parameter, such as:
public void DoThis(bool aValue = false) {...}
Using Visual Studio 2010, I am able to compile it. But I cannot do it with MSBuild:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild /clp:ErrorsOnly D:\folder\mySolution.sln
ln
Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5448]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
UpdatedClass.cs(29,94): error CS0241: Default parameter specifiers are not permitted
Well, optional parameters are not permitted using this compiler. So can I add an extra argument in this MSBuild command, to ignore this kind of error?
Or do I have to compile the project using C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe ?
Is this safe regarding asp.net projects?
If you are using C# 4 syntax, you have to use a 4.0 compiler. And this means you need to run .Net 4.0 on the server where you intend to deploy this code. Alternatively - rewrite the code not to use default parameters, that's not hard - just add an overload like this:
public void DoThis() {DoThis(false);}
public void DoThis(bool aValue) {...}

Liferay 6 on Glassfish 3.1 - issue using liferay-ui tags in portlet jsp files

We are seeing this issue on our current Glassfish 3.1 cluster setup. Below are details of issue
- We are running Glassfish version 3.1
We are running liferay 6.0.6
The liferay war is deployed on the Glassfish cluster and working fine on both the nodes.
The same liferay war works fine one Tomcat server as well.
When we deploy our custom portlets on Glassfish cluster it starts working immediately after deployment. (before doing a restart of glassfish cluster)
Once we do a restart of the cluster nodes the same portlet application stops working and Complains and give attached error.
My research till now shows that the java.lang.NoClassDefFoundError: com/liferay/portal/util/PropsValues is part of portal-impl.jar file which is part of liferay portal and should be made available to our portlet. Somehow after the restart the jar files are loaded in a different manner and the same jar file is not available to portlet.
We have also tried the Glassfish 3.1 Bundled liferay 6.1 setup and see the same issue on it as well.
As suggested by liferay forums we have placed the portal-service.jar and portlet.jar in [glassfish home]/lib directory.
when we do a lsof -p pid on the glassfish node instance process it shows the required jar file is open by this process. Not sure why is this not available to our application.
I would appreciate any help or pointers to resolve/investigate this issue.
java.lang.NoClassDefFoundError: com/liferay/portal/util/PropsValues
at org.apache.jsp.html.taglib.ui.search_005fiterator.page_jsp._jspService(page_jsp.java from :500)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72) at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217) at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:534) at com.liferay.taglib.util.IncludeTag.include(IncludeTag.java:323)
at com.liferay.taglib.util.IncludeTag._doInclude(IncludeTag.java:418)
at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:92)
This is a related thread on liferay forum by me but I have not really got any response on it from anyone. [Same issue posted on liferay Forum]
i have also tried placing portal-impl.jar in my portlet/WEB-INF/lib dir (which is not recommended way) and I failed since it requires me to bring all other dependent jars in it too.
I am now running out of options and thinking about implementing the pagination feature using some other third party library instead of using liferay tags.
Here is the specific tag which is giving us error
<liferay-ui:search-iterator />
List of jars in my portlet WEB-INF/lib folder
SiebelClientWS-0.0.1-SNAPSHOT.jar
spring-asm-3.0.5.RELEASE.jar
XmlSchema-1.4.7.jar
spring-aspects-3.0.5.RELEASE.jar
aspectjrt-1.6.11.jar
spring-beans-3.0.5.RELEASE.jar
aspectjweaver-1.6.11.jar
spring-context-3.0.5.RELEASE.jar
axiom-api-1.2.11.jar
spring-context-support-3.0.5.RELEASE.jar
axiom-impl-1.2.11.jar
spring-core-3.0.5.RELEASE.jar
axis2-1.5.4.jar
spring-expression-3.0.5.RELEASE.jar
axis2-kernel-1.5.4.jar
spring-jdbc-3.0.5.RELEASE.jar
axis2-transport-http-1.5.4.jar
spring-tx-3.0.5.RELEASE.jar
axis2-transport-local-1.5.4.jar
spring-web-3.0.5.RELEASE.jar
c3p0-0.9.1.2.jar
spring-webmvc-3.0.5.RELEASE.jar
commons-codec-1.4.jar
spring-webmvc-portlet-3.0.5.RELEASE.jar
commons-httpclient-3.1.jar
util-bridges.jar
commons-logging.jar
util-java.jar
flexjson-2.1.jar
util-taglib.jar
httpcore-4.0.jar
woden-api-1.0M9.jar
httpcore-nio-4.0-beta1.jar
woden-impl-commons-1.0M9.jar
log4j.jar
woden-impl-dom-1.0M9.jar
neethi-2.0.2.jar
wsdl4j-1.6.2.jar
spring-aop-3.0.5.RELEASE.jar
wss4j-1.6.2.jar
I changed
/html/taglib/ui/search_paginator/page.jsp
/html/taglib/ui/search_iterator/page.jsp
/html/taglib/ui/page_iterator/start.jsp
and removed the calls to PropsValues and replaced them with calls to the com.liferay.portal.kernel.util.PropsUtil and PropsKeys instead and that go the rid of the error for me.
I made an improvement request
http://issues.liferay.com/browse/LPS-30660
com/liferay/portal/util/PropsValues is part of portal-impl.jar file which is part of liferay portal and should be made available to our portlet.
That is not true, portal-impl.jar is not available to your portlets and it is not meant to. You MUST NOT put it in your WEB-INF/lib. That jar is only available, and should be that way, to Liferay (liferay application).
Can you show contents (list of jars) of your (deployed) portlets WEB-INF/lib?

Resources