Solved

Help with accessing .application file using VB.NET

Posted on 2015-02-09
20
60 Views
Last Modified: 2015-02-11
Hi,

I have multiple applications deployed using clickonce technology, which creates applicationname.application. How do I access these applications if they are in the same folder as my application's folder?

Thanks,

Victor
0
Comment
Question by:vcharles
  • 11
  • 6
  • 3
20 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 40598647
You normally don't. ClickOnce applications are located in the ClickOnce application cache.  This implies a kind of isolation from the rest of the system.

btw, what exactly do you mean by "access these applications"?
0
 

Author Comment

by:vcharles
ID: 40598714
When i click on the .application file (project.application) the project executes, is the a way to execute the file by code from a application folder?  I would like to consolidate multiple application in one application's  folder.
0
 
LVL 33

Expert Comment

by:ste5an
ID: 40598737
ClickOnce is meant to be an easy, somehow lightweight installation. Thus this kind of caching and the implied isolation of the rest of the system.

Okay, now you've got my: How is your application deployed to the application folder (program files)?

Do you want a single ClickOnce package for all applications?
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:vcharles
ID: 40598762
Yes, I would like one single clickonce package containing multiple project.applications along with their application folders.
0
 
LVL 33

Expert Comment

by:ste5an
ID: 40598779
Choose one of your projects as "master". This means that you add the others either as dependcy or add the compled assembly (.exe) as content to your project.
0
 

Author Comment

by:vcharles
ID: 40598925
Hi,
Is there a way to execute the project.applicqtion files?
Victor
0
 
LVL 40
ID: 40599152
If the entry point is always in the same application, make the other ones dlls that you will distribute with your program. From the entry point, you will have access to all the dlls.

I you write your own Main routines, you might have to change them a bit and maybe give them another name to prevent confusion. Then, call that method as you would call a method in any dll.

If you start your applications by specifying a startup Form, then simply open that startup Form from your entry application as needed.
0
 

Author Comment

by:vcharles
ID: 40599878
Hi,
How do i convert the applications to a dll and execute them using vb.net using butt I n click event?
Thanks,
Victor
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40600159
You convert an application to a dll by changing the Application type to a Class Library in the Application tab of the project's Properties window.

It can be straightforward, or can require minor modifications of the starting code, depending on how each application is launched.

Then, in your main application, you add a reference to each dll.

As I told you before:

I you write your own Main routines, you might have to change them a bit and maybe give them another name to prevent confusion. Then, call that method as you would call a method in any dll.

If you start your applications by specifying a startup Form, then simply open that startup Form from your entry application as needed.


Supposed you were starting in a form, the code of your button would be the following:

Dim frm As New YourDllNamespace.YourForm()
frm.Show

YourDllNamespace would be the namespace of the dll, that is by default the name of the dll, but might have been changed in the dll project's Properties window. YourForm is the name of your form.

This would display the form that was launched previously when the application started, so normally everything should flow as it did before from there.
0
 

Author Comment

by:vcharles
ID: 40601551
Hi,

Thanks for the instructions, I am able to access the Form, but receiving  error message  :Object regerence not set to an instance of an object", trying  to identify what is causing this error.
0
 

Author Comment

by:vcharles
ID: 40601739
Hi,

I can't  access my data files  using  applucation.Startpath when using  the dll.

Victor
0
 
LVL 40
ID: 40601912
I just tested here and have not problem (with Application.StartupPath)

Are you sure that the files are distributed with the application?

What is the exception that you receive.

Can you show us your code?
0
 

Author Comment

by:vcharles
ID: 40602353
Hi,

I am using the code below to access a PDF  in a button click event:

Process.Start(Application.StartupPath & "\Search_Manual.pdf")

and the code below in the FormLoad event to use LinkFinal.xml in a dataset

  Dim curfile As String = (Application.StartupPath + "\linkFinal.xml")
            fslinkBEL = New System.IO.FileStream(Application.StartupPath + "\linkFinal.xml", IO.FileMode.Open)
            dtsetlinkBEL.Clear()
            dtsetlinkBEL.ReadXml(fslinkBEL)
            fslinkBEL.Close()  
          Dim sec As New Security
            For t As Integer = 0 To dtsetlinkBEL.Tables.Count - 1
                For i As Integer = 0 To dtsetlinkBEL.Tables(t).Rows.Count - 1
                    For j As Integer = 0 To dtsetlinkBEL.Tables(t).Columns.Count - 1
                        dtsetlinkBEL.Tables(t).Rows(i).Item(j) = sec.psDecrypt(dtsetlinkBEL.Tables(t).Rows(i).Item(j))
                    Next

                Next
            Next

I receive the same errors for both code eventhough both LinkFinal and Search_Manual.pdf fare included in the project.

Victor
0
 

Author Comment

by:vcharles
ID: 40602412
Hi again,

The properties of both files are set to content, is this the correct setting?

Victor
0
 
LVL 40
ID: 40602436
Looks OK, but what is the error you get?

Content usually does the job by default for external files, but you can verify.

Check under the Application Files of the Publish tab that you use to set up your deployment. Make sure that your files are there, marked as Include and Required.

If so, then look into the installation directory to see if the files are there. That directory has a random name that changes with each deployment, so simply add a MessageBox that shows the Application.StartupPath, redeploy and run the application for the MessageBox to show you the name of the directory. Verify that your files are in there.
0
 

Author Comment

by:vcharles
ID: 40602801
Hi, the error is can mot find the xml oe pdf fike.
0
 

Author Comment

by:vcharles
ID: 40602846
I was using the regular setup method and including the xml and pdf files in the dll project, will publish the main  application when i get to the office snd get. back  to you.  Error message  is can not find file in application's  folder.

Thanks,

Victor
0
 
LVL 40
ID: 40603260
A ClickOnce installation is based on the application. There is no Publish tab for a dll project. So the files have to be in the Application project and marked as Content for the application, not the dll project. Otherwise, they are not included in the application package.
0
 

Author Comment

by:vcharles
ID: 40604423
Hi,

Got it.

Thank You.

Victor
0
 
LVL 40
ID: 40604530
This Visual Studio / .NET framework is so powerful. But there are so many little details to know before you feel at ease in that monster.

Glad I could help.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question