|
POST
|
Yes thank you, I have that in my code from the 2.x days.
... View more
07-15-2022
07:36 AM
|
0
|
0
|
1728
|
|
POST
|
Ok your alternative code works! Thank you so much. I made some very small modifications so that we can keep the prior logic, and it that doesn't work then use the new logic. I also wrapped the GUID with squigglies as that is probably what users expect. I also didn't want an exception thrown so on a fail I just return an empty string. Here is my mod to your code: /// <summary>
/// Get the current add-in module's daml / AddInInfo Id tag (which is the same as the Assembly GUID)
/// </summary>
/// <returns></returns>
public static string GetAddInId()
{
// Module.Id is internal, but we can still get the GUID from the assembly
var assembly = Assembly.GetExecutingAssembly();
//var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
object[] custAtts = assembly.GetCustomAttributes(typeof(GuidAttribute), true);
Debug.Print("custAtts.Count={0}", custAtts.Count());
if (custAtts.Count() > 0)
{
GuidAttribute attribute = (GuidAttribute)custAtts[0];
string aguid = string.Format("{{{0}}}", attribute.Value);
return aguid;
}
else
{
// if no custom attributes returned then try through the assembly location which has the GUID
// embedded in the path.
Debug.Print("assembly.Location={0}", assembly.Location);
var dirs = assembly.Location.Split(Path.DirectorySeparatorChar);
if (dirs.Length > 2 && Guid.TryParse(dirs[dirs.Length - 2], out Guid assemblyGuid))
{
Debug.Print("assemblyGuid={0}", assemblyGuid.ToString());
string aguid = string.Format("{{{0}}}", assemblyGuid.ToString());
return aguid;
}
else
{
//throw new Exception($@"Assembly path doesn't contain a GUID: {assembly.Location}");
Debug.Print($@"Assembly path doesn't contain a GUID: {assembly.Location}");
return string.Empty;
}
}
} I
... View more
07-14-2022
11:22 AM
|
1
|
0
|
1742
|
|
POST
|
@Wolf thank you so much. I also sent you some suggestions on the class methods.
... View more
07-14-2022
08:49 AM
|
0
|
0
|
1751
|
|
POST
|
Yes I did and it works IF you know the file path of the addin. To know the path of the Addin you need the guid. So to get the guid, you need the guid. // 1. get the filename of this .esriAddinX file
var fileName = AddIn.GetAddInId();
// 2. get the config.daml content from the esriAddinX file
var versionTuple = AddIn.GetConfigDamlAddInInfo(fileName);
MessageBox.Show($@"Version: {versionTuple.Version} desktopVersion: {versionTuple.DesktopVersion} Id: {Module1.Id}"); But again this fails for me on line 2.
... View more
07-14-2022
08:24 AM
|
0
|
0
|
2479
|
|
POST
|
Unfortunately my knowledge base is limited when it comes to the writing of the assembly. But my tests showed that something is missing.
... View more
07-13-2022
11:38 AM
|
0
|
0
|
1770
|
|
POST
|
I looked up the documentation and it seems that parameter for isInherit is required in the call but ultimately ignored in GetCustomAttributes .
... View more
07-13-2022
11:37 AM
|
0
|
0
|
2498
|
|
POST
|
Ok this is very odd. I thought I had changed something that broke it. But I just created a brand new Addin with the VS template, added a button, added the Addin and Extensions classes. It still bombs at the same line. My guess is that a project migration from Framework to Core keeps some properties while a brand new project based on Core doesn't have them. Idk.
... View more
07-13-2022
10:53 AM
|
0
|
2
|
2504
|
|
POST
|
@Wolf that is still a no-go for me. The line where it crashes is same as before var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0]; When I run string guidStr = AddIn.GetAddInId(); it seems that the function GetCustomAttributes returns an empty collection. Rather odd since I started this project from scratch and used the guide here https://developers.arcgis.com/documentation/arcgis-add-ins-and-automation/arcgis-pro/tutorials/build-your-first-add-in/. I did however go to the Project Properties and change some stuff there. Mainly default namespace and assembly version. Mainly in the Package section.
... View more
07-13-2022
06:54 AM
|
0
|
2
|
2518
|
|
POST
|
So tried your code and I'm getting a null on line 3. I also tried just the plain jane GetCustomAttributes() and that also returns zero elements.
... View more
07-12-2022
11:14 AM
|
0
|
0
|
2572
|
|
POST
|
At Pro 2.9 there was this great helper class that got info for your own addin. https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Content/AddInInfoManager It bombs at 3.0 and I have not been able to locate an alternative API or other form of getting the info programmatically. I tweaked the function and it turns out the the code is returning zero guid attributes: public static string GetAddInGuid()
{
// get the GUID that identifies the current add-in
Assembly exAssembly = Assembly.GetExecutingAssembly();
//GuidAttribute gAttribute = (GuidAttribute)exAssembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
object[] custAtts = exAssembly.GetCustomAttributes(typeof(GuidAttribute), true);
if (custAtts.Length == 0)
{
throw new Exception("No custom attributes.");
}
GuidAttribute gAttribute = (GuidAttribute)custAtts[0];
// guid={903288ab-2c9c-4e49-8a3d-0321f68425c1}
return string.Format("{{{0}}}", gAttribute.Value);
} Anyone know an alternative to programmatically get info for your own addin or just the GUID?
... View more
07-12-2022
10:47 AM
|
0
|
17
|
4335
|
|
POST
|
So after experimenting with a few controls I settled on a ProWindow. It is only displayed by the user action and it is non-modal. Ignore the lame graphic I have:
... View more
07-12-2022
07:50 AM
|
0
|
1
|
1525
|
|
POST
|
Interesting. Almost everything I have read up to now says to use Content.
... View more
07-12-2022
06:55 AM
|
0
|
0
|
2179
|
|
POST
|
So working on our company Addin off and on. I've added some Button and DockPane controls and have used custom images with BuildAction=Content. It all works great. I've extended the functionality with a Pane and ProWindow control but could not get any images to display. It dawned on me that maybe I was doing something wrong. From the forum I found a post that said use BuildAction=Resource. So I did that and it worked!!! So my question is...what is the difference? Why do we need two options? Why wouldn't the control auto detect that a BuildAction on the graphic is not compatible? What if I need the same graphic in various controls that use Content and Resource? Do I have to add it twice?
... View more
07-11-2022
06:04 PM
|
0
|
2
|
2239
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-25-2020 09:25 PM | |
| 1 | 08-17-2022 11:17 AM | |
| 1 | 07-24-2022 01:36 PM | |
| 1 | 07-14-2022 11:22 AM | |
| 1 | 07-14-2022 10:29 AM |
| Online Status |
Offline
|
| Date Last Visited |
Monday
|