I made the jump from VS 2010 (VB) all the way to VS 2017, and that may have been a mistake. I've already been slowed down with bugs, which I have reported. My latest concern is about accessing a global functions class that I have never had a problem with in VS 2010. I have reported it and it is in triage, but I wanted to make sure that something hasn't changed in the versions since 2010, hoping someone here can tell me.
Essentially what happens is that the global class, no matter how it is configured, is not recognized by any other class. Including a reference in a form class causes the IDE to tag it as an error. For example, the code in the GlobalFunctions.vb document:
Public Class GlobalFunctions
Public Function DecodeBase64(strEncoded As String) As String
Dim byt As Byte() = Convert.FromBase64String(strEncoded)
Return (System.Text.ASCIIEncoding.ASCII.GetString(byt))
End Function
Public Function EncodeBase64(strUnencoded As String) As String
Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(strUnencoded)
Return (Convert.ToBase64String(byt))
End Function
End Class
and the calling methods from a form page:
If elemSetting.Attributes("name").Value = "LoginName" Then
Session("MailLoginName") = globalfunctions.DecodeBase64(elemSetting.Attributes("value").Value)
End If
If elemSetting.Attributes("name").Value = "LoginPass" Then
Session("MailLoginPass") = globalfunctions.DecodeBase64(elemSetting.Attributes("value").Value)
End If
Here the errors are being highlighted in the IDE:
And the error messages in the error list:
Understand, too, that I have tried as many variations of declarations as I can think of, such as "Public Shared Function," making the calling sub Shared, defining the global functions document as a Class or a Module, etc. Nothing works.
I've also tried placing the GlobalFunctions.vb class in the project's root directory and in a directory named App_Code, as was suggested in some blog posts around the net.
And since I have had no trouble like this with VS 2010, I assume it's a bug in 2017, which, as I said, I have reported. But I wanted to check with better minds than my own to see if I have overlooked something that may have changed somewhere between 2010 and 2017.
Can someone tell me if I am doing something wrong? Or maybe reaffirm for me that this is, indeed, a bug?
Thanks!
Try to delete and recreate your GlobalFunction.vb as maybe by renaming it in the past it didn't correctly correct everywhere in the project.
I think this is normal. You are using a Class and not a Module so you would need to declare a new instance either call like this:
Dim Globaler As New GlobalFunctions
If elemSetting.Attributes("name").Value = "LoginName" Then
Session("MailLoginName") = Globaler.DecodeBase64(elemSetting.Attributes("value").Value)
End If
If elemSetting.Attributes("name").Value = "LoginPass" Then
Session("MailLoginPass") = Globaler.DecodeBase64(elemSetting.Attributes("value").Value)
End If
Or use a Module and you wont need to declare a new instance.
Also if it still can't be accessed you should check the fact that maybe you just included the file to the solution without including it to the project
To Add new class:
Solution Explorer
Right Click your Project Name (above My Project)
Add
Class
Related
I am making an asp.net web application with vb coding behind. I found a code online for making a multilingual website, and as the original code is in C# I made a C# project to try it. Everything went fine. Now, I converted the code to VB to use it on the original project, and for some reason, the Debugging doesn't want to start, always throwing MissingManifestResourceException as an error. The resource files' Build Action is set to Embedded Resource, and the Code I am using is this:
Dim rm As ResourceManager
Dim ci As CultureInfo
Private Sub LoadString()
Thread.CurrentThread.CurrentCulture = New CultureInfo(Session("Lang").ToString())
rm = New ResourceManager("WebApplication6.App_GlobalResources.Lang", Assembly.GetExecutingAssembly())
ci = Thread.CurrentThread.CurrentCulture
NavigationMenu.Items(0).Text = rm.GetString("MenuItemDefault", ci)
NavigationMenu.Items(1).Text = rm.GetString("MenuItemAbout", ci)
End Sub
Where "Lang" is the name of the base Resource File. The files' name:
Lang.en-US.resx, Lang.es-ES.resx
The whole error looks like this:
MissingManifestResourceException was unhandled by user code
Could not find any resources appropriate for the
specified culture or the neutral culture. Make sure
"WebApplication6.App_GlobalResources.Lang.resources" was correctly embedded or linked into
assembly "WebApplication6" at compile time, or that all the satellite
assemblies required are loadable and fully signed."
Again, in C# the whole thing worked. This code is Placed in a function, which is called from the Load_Page form.
Thanks in advance for your help!
After spending hours trying to figure out, I found a solution.
What I did was replace this string:
rm = New ResourceManager("WebApplication6.App_GlobalResources.Lang", Assembly.GetExecutingAssembly())
With this one:
rm = New ResourceManager("WebApplication6.Lang", System.Reflection.Assembly.Load("WebApplication6"))
But removing "App_GlobalResources" from the original string also worked. So the other posible solution is:
rm = New ResourceManager("WebApplication6.Language", Assembly.GetExecutingAssembly())
After replacing the string I just left everything else as it is in the main post. Now everything's working fine.
How can I, with X++, create a sales order from a sales quotation in AX 4.0? I've searched and found the same answer several places, however it seems to be specific to newer versions of AX.
This is what I've found here: https://community.dynamics.com/ax/b/mafsarkhan/archive/2014/04/14/create-sales-order-from-sales-quotation
static void createSalesOrderFromQuote(Args _args)
{
SalesQuotationTable salesQuotationTable = SalesQuotationTable::find("");
SalesQuotationEditLinesForm editLinesForm;
ParmId parmId;
editLinesForm = SalesQuotationEditLinesForm::construct(DocumentStatus::Confirmation);
parmId = editLinesForm.parmId();
editLinesForm.initParmSalesQuotationTable(salesQuotationTable);
editLinesForm.parmTransDate(systemDateGet());
editLinesForm.prePromptInit();
editLinesForm.initParameters(NoYes::No, NoYes::No, NoYes::No, NoYes::No, NoYes::No, '', NoYes::No);
editLinesForm.run();
}
The line editLinesForm.prePromptInit(); wont compile and I guess that is due to only being available in newer versions. I can comment it out and the code will compile and run. However, even though I've added the ID of the SalesQuotationTable like this: ... ::find("123456") It's seems the code converts ALL my quotations to salesorders, however I've yet to confirm this as I've been forced to kill the process to start working again.
I think you may comment out the call to editLinesForm.prePromptInit() from your method.
In order to not post all quotations into sales orders I would try to reproduce the main() method of the SalesQuotationEditLinesForm class in your system, omitting the logic related to datasource.
If I refer to my system I think your code might be missing:
editLinesForm.getLast();
editLinesForm.parmId(parmId);
before calling editLinesForm.run()
I am having trouble with iTextAsian which cause me done nothing but finding solution all this week, it would be great if I can have the solution here.
My situation is I have a project which is using iTextSharp for a while, I had two blocks of code as following, please note that both of them are worked for me
Block 1:
Private Function aFunc() as returnType
iTextSharp.text.io.StreamUtil.AddToResourceSearch(
System.Reflection.Assembly.Load("iTextAsian")
)
Dim font As Font = MyPDF.GetFont
End Function
Protected Friend Shared Function GetFont() As Font
Return New Font(
BaseFont.CreateFont(
"STSong-Light",
"UniGB-UCS2-H",
BaseFont.NOT_EMBEDDED
)
)
End Function
Block 2 (current)
Public Shared Function GetChineseFont() As iTextSharp.text.Font
iTextSharp.text.io.StreamUtil.AddToResourceSearch(
System.Reflection.Assembly.Load("iTextAsian")
)
Return New Font(
BaseFont.CreateFont(
"STSong-Light",
"UniGB-UCS2-H",
BaseFont.NOT_EMBEDDED
)
)
End Function
I am using iTextAsia2.1 and it used to work fine for me, but it start to pop me ""Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized."" exception on my development server since last week.
The weirdest thing is the version of my website between dev and production server are same, but this block of code worked only on production server, I am wondering whats the matter and I am afraid that one day this exception will appear on my production server.
Please suggest me some solution please.
Thanks for your time!
Are you taken update?
The error will come when some clash between older version and newer version or font missing etc. please check this link.
http://www.excindex.com/web/831818.html
http://www.csharpcode.info/ask-235324.html
http://itext-general.2136553.n4.nabble.com/Asian-font-not-recognized-after-update-td2991134.html
http://stderr.org/doc/libitext-java-doc/www/tutorial/ch09.html
Before you start anything, What I think, you just download your production all dll and put in your local development. Check wheather the issue solved
Sorry all, I finally figure it out, its because the following block should not contains in a Shared function
iTextSharp.text.io.StreamUtil.AddToResourceSearch(
System.Reflection.Assembly.Load("iTextAsian")
)
I now called this line in Application_Start of global.asax and the problem is solved, thanks for your time and suggestions!
I am running into a problem when creating a SharePoint 2010 Feature. What I am trying to do is:
Check to see if the site name is the same as the site title.
If it isn't, change the name (and therefore the URL) to match the title.
My code is as follows:
Private Sub ChangeSiteNameToMatchTitle()
_web = SPContext.Current.Web
If _web.Name <> _web.Title Then
_web.Name = _web.Title
_web.Update()
End If
_web.Dispose()
End Sub
This successfully changes the name so that it's identical to the site title, but it causes the Feature to crash at the end of it's activation cycle due to the fact that the site name (and therefore the URL) has changed.
The Feature appears to be trying to reload the ManageFeature.aspx page on the site that activated it, but since the URL has changed it cannot find the page any more.
Does anyone know of a workaround for this, or even if it's possible?
Many thanks!
I would make the Feature hidden and activate it outside of the UI using PowerShell.
Also, per best practice rule SPDisposeCheckID_220, you should not dispose SPContext.Current.Web:
SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite and SPWeb objects returned by SPContext.Site, SPContext.Current.Site, SPContext.Web, and SPContext.Current.Web.
I am trying to work with browseForOpenMultiple function inside Flex, sdk 3.5, I am trying to figure out a bug. The browseForOpenMultiple does not crash everytime, but it seems as though I can upload a file once, but when I go to upload a second file, it crashes when the browseForOpenMultiple function is called. Anyone have any ideas about possible causes?
Update:
private function browseForFiles():void
{
fileBrowser = new File();
fileBrowser.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
fileBrowser.addEventListener(Event.CANCEL, fileSelectionCancelled);
fileBrowser.browseForOpenMultiple("Select Desired Media File(s)", [(mode == "Media")? MediaTypes.getFileFilter() : MediaTypes.getVideoFilter()]);
}
So the code in our array of file extensions was crashing when there were over 60 items listed in an array that gets converted into a string for the FileFilter. This may not be an Adobe limit, but I wanted to make mention that the crash is fixed, so that others who may be encountering issues with browseForOpenMultiple will know what the issue was for this problem. This is not code that I originally wrote, so I will check into it for more clues, but for the time being, too many array items being joined together into a string for FileFilter object caused the crash.
It could be how it's construct the File, without a real file reference.
Try something like this :
var fileBrowser = File.desktopDirectory