Vault 2017 Web App Log In issue

Vault 2017 Web App Log In issue

Anonymous
Not applicable
1,010 Views
1 Reply
Message 1 of 2

Vault 2017 Web App Log In issue

Anonymous
Not applicable

Hi All,

 

I'm having a bit of trouble logging in to the Vault from a web application.

 

I found a post on the forum explaining how to solve the problem but for some reason it's not working for me. 

Older post on the forum: Older Post Vault Web App Login Issue

 

I will try to explain the steps I've followed to solve the problem, and what the issue is.

 

1.  Started a new project in Visual Basic 2015 - ASP.NET Web Application (.NET Framework)

 

2.  Created a new Web Form "Default.aspx" and made some controls (textbox and buttons to mimic the vault login form).

     The code behind this form (just the login action):

     

using System;
using VDF = Autodesk.DataManagement.Client.Framework;

namespace VaultWebApplication.web_forms
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void submitEventMethod(object sender, EventArgs e)
        {
            try
            {
                VDF.Vault.Results.LogInResult results =
                VDF.Vault.Library.ConnectionManager.LogIn(serverTextBox.Text, vaultTextBox.Text, usernameTextBox.Text,
                passwordTextBox.Text, VDF.Vault.Currency.Connections.AuthenticationFlags.ReadOnly, null);

                resultTextBox.Text = results.Success.ToString();
            }
            catch (Exception ex) { resultTextBox.Text = "Error: " + ex.Message.ToString(); }
        }
    }
}

 3. I've made a Global.asax with code behind:

 

using System;
using System.Globalization;
using System.Text.RegularExpressions;

using Autodesk.Connectivity.WebServices;
using Autodesk.Connectivity.WebServicesTools;
using System.Reflection;

namespace VaultWebApplication
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        #region Assembly Resolver

        private static Regex assemblyRegEx;
        private static bool Is64Process = false;

        static WebApiApplication()
        {
            
            Is64Process = IntPtr.Size == 8;
            InitRegEx();
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        }

        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            if (IsXmlSerializer(args.Name)) { return null; }

            string[] fields = args.Name.Split(',');
            string assName = fields[0];

            if (assName.EndsWith(".resources", StringComparison.InvariantCultureIgnoreCase)) { return null; }

            Assembly ass = null;

            try
            {
                // First try to locate the assembly in the list of loaded assembly of the current AppDomain
                AssemblyName name = new AssemblyName(args.Name);
                Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly assembly in assemblies)
                {
                    if (name.Name == assembly.GetName().Name) { return assembly; }
                }
                ass = Assembly.LoadFrom(args.Name);
            }
            catch
            {
                // Try to locate the assembly in the directory that contains the AddIn type.
                string basePath = System.IO.Path.GetDirectoryName(new Uri(MethodBase.GetCurrentMethod().DeclaringType.Assembly.CodeBase).LocalPath);
                string subFolder = Is64Process ? "x64" : "x86";
                string assemblyFileName = System.IO.Path.Combine(basePath, string.Format(CultureInfo.InvariantCulture, "{1}\\{0}.dll", new AssemblyName(args.Name).Name, subFolder));

                if(System.IO.File.Exists(assemblyFileName))
                {
                    ass = Assembly.LoadFile(assemblyFileName);
                }
                else
                {
                    string fout = new AssemblyName(args.Name).Name;
                }
            }
            finally { }
            return ass;
        }

        private static void InitRegEx()
        {
            string regex = @"^([\w\.]+)XmlSerializers";
            RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
            assemblyRegEx = new Regex(regex, options);
        }

        private static Boolean IsXmlSerializer(string name)
        {
            return assemblyRegEx.IsMatch(name);
        }

        #endregion

        protected void Application_Start(object sender, EventArgs e)
        {           
            //Active License
            WebServiceManager.AllowUI = false;
            LicenseManager.Instance.SetActive();
        }
    }
}

4. Made a "x64" and "x86" folder in the project and added the necessary .dll's in the folders

 

5. Added the clmloader.dll to my debugfolder

 

6. In the web.config file

 

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="Licensing" type="Autodesk.Connectivity.WebServices.LicensingSection, Autodesk.Connectivity.WebServices" />
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <identity impersonate="false"/>
    <customErrors mode="Off"/>
  </system.web>
  <Licensing edition="professional"/>
</configuration>

7. Add User to the IIS application pool and opened a Vault Client with the same user cred's

 

IIS.PNG

 

8. The vault user I use to try to login has Admin rights

 

But when I try this I get this as exception message:

 

"de type-initialisatiefunctie voor autodesk.connectivity.webservicestools.webservicemanager heeft een uitzondering veroorzaakt."

 

rough translation:

 

"the type of initialisation function for autodesk.connectivity.webservicestools.webservicemanager has caused an execption."

 

Can someone help me with this?

Thanks in advance

 

 

 

 

0 Likes
1,011 Views
1 Reply
Reply (1)
Message 2 of 2

psaarloos
Collaborator
Collaborator

Hi David,

 

All of this is looking alright. The only major difference is that you are using the ConnectionManager (VDF) to create a connection, while I am using the WebServiceManager (lower level API). I've posted the sample application in the older post. Please let me know if it works for you.

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!