Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
What I am trying to do is setup Visual Studio 2017 Enterprise to have it help me keep track of my code architecture better. I am running on Windows 8.1 if that makes any difference. An example will (hopefully) demonstrate what I mean:
If I want to use the sine function, Visual Studio insists that I pre-pend Math. in front of it: Rise = Math.sin(Angle)
What I want to do is have the same behavior for libraries that I have created. I have created a class called K2Math (called out as Public Class K2Math) and in it are functions like: Public Shared Function CheckForCollinear( . . . ) as Boolean. I have bundled it up into a separate DLL.
In my caller code, in the project references I have a reference to K2Math.DLL. As the functions are Public Shared, I don't have to use 'New K2Math' setup call like I would with a more conventional DLL. However, in the caller program I can use the CheckForCollinear function without having to pre-pend K2Math. I can also call it using K2Math.CheckForCollinear and the compiler doesn't complain.
What I would like the compiler to do is complain and force me to pre-pend the K2Math. This would help to make it obvious to me or whoever is reading my code how the code is architected and segregated.
But I can't seem to figure out how to do that. Also, I haven't figured out how to succinctly pose the question to do a proper Google search.
If I am being unclear, please so note that and I'll try to clear things up.
Create a Library lets say CustomizedMathLibrary
In that create a class K2Math. WRAP in a NAME SPACE (This is important)
Build and Use It by Importing name space in your code.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
microsoft.office.interop.excel is missing but I need to be able to check for it to prevent this error.
If the reference doesn't exist (it's not installed on my computer), I'd like to conditionally load something else instead.
I tried to show a picture but I haven't had enough posts so I'm not allowed to do so yet.
This is more about addressing runtime errors where an assembly isn't found; you can't publish your code if it won't even compile. You'll need to either add the missing dll or install Excel to compile.
You can add this handler to your project's (static) type initializer:
AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf EmbeddedAssembly.GetMissingAssembly
(I have a class called EmbeddedAssembly with a method GetMissingAssembly() but you can simply call a sub/function such as MissingReference() if you like.)
The function signature looks like most handlers but note the event argument (e) type:
Public Shared [Sub|Function] GetMissingAssembly(
ByVal s As Object,
ByVal e As ResolveEventArgs) [As Assembly]
In the handler you can decide what to do, whether it's throw an error or, better, unpack and use an assembly embedded in your project's Resources.
There're plenty of references on S.O. about embedding assemblies as Resources. Another option is FodyWeavers which you can also find info about here. I've moved to the latter from the former mainly because it works and is less work or maintenance.
I should add a warning that when I first started resolving and embedding assemblies, etc, it was a fairly steep learning curve, especially since my project was a commercial app which had to be bullet-proof. My recommendation is create a small test project and get that all working first before you jump in with something more complicated.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I've developed a console application that does a lot of routines, but the Antivirus detected it as a malware of type Gen:Variant.Ursu.56053.
How can I fix this without touching the antivirus policy because it's not allowed for us to create any exceptions for any found threat.
I'd like also to mention that If i changed the assembly name the antivirus is no longer consider the new file virus, but it looks that it considers it virus because I invoke it many times, with different parameters.
Any suggestions, I'm really suffering from this,
I know this thread is very old, but for people which will come here - to fix this issue simply add icon to the program, im not even joking, it works.
FALSE +VE ALERT!!! Many antivirus engines have name pattern matching as their Swiss-knife to detect malicious files,If any of them matches the name they have in their Database then you can't do much about it. Its simply became a False +ve !!! Also your assembly name should consist of the technology area and component description, or company name and technology area (depending on your preferance). So try changing it to more specific one. :)
Assuming that you are talking about .NET (with relation to Visual Studio) For Ex:
Project: Biometric Device Access
Assembly: BiometricFramework.DeviceAccess.dll
Namespace: ACME.BiometricFramework.DeviceAccess
I had the same problem with Bitdefender, but mine is a Gen:Variant.Ursu.787553 when I tried creating a .exe file from my C program.
I simply moved it out of quarantine manually, and it worked well. You might have to that every time you build a new program. Hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a very old VB project I am looking to modernize to which I created a new solution (will convert code to C# later on), am re-adding the libraries and web projects to the new solution to eliminate the old project having old .publishproj, references to mscorlib 2.0 (despite best efforts to resolve through re-adding references) and several other issues that will likely go away.
In the process, I figured to try to go to .NET Standard for the standardized PCL that will allow for future use with Xamarin, Mono, etc. I am not fully versed in .NET Standard so need some input (attempting 2.0 based on the scaling effect of 2.0 down from what I read)
The problems I am running into are:
1) I have several basic CORE functions from the .NET Framework that are not recognized in .NET Standard:
IsNumeric, IsNothing, IsDBNull, IIF
Any suggestions as to why this is?
(re-edit to remove Hold)
Thank you to jmcilhinney for answering :-)
All four of IsNumeric, IsNothing, IsDBNull and IIf are VB-specific. They can't be part of .NET Standard if they've never been accessible to other languages without referencing the Microsoft.VisualBasic assembly. You really shouldn't have been using any of them previously anyway as they are holdovers from VB6.
In the case of IsNumeric, it uses Double.TryParse internally anyway. In fact, Double.TryParse was written specifically to improve the performance of IsNumeric. You should be using the TryParse method of the appropriate numeric type yourself if you want to know whether a String can be converted to that type.
In the case of IsNothing, you should simply be comparing your reference to Nothing, e.g. instead of:
If IsNothing(myThing) Then
you should be using:
If myThing Is Nothing then
In the case of IsDBNull, you should be doing much as above, e.g. instead of:
If IsDBNull(myThing) Then
you should be using:
If myThing Is DBNull.Value Then
That said, both a DataRow and a data reader have their own dedicated methods to tell you whether one of their fields is NULL.
In the case of IIf, it always had it's issues because it is a method that people tried to treat like an operator in many cases. I think it was VB 2008 that actually did introduce an If operator that works much like the C# ternary operator, so you should have been using that since then anyway, e.g. instead of:
myVar = IIf(someBooleanExpression, someValue, someOtherValue)
you should have been using:
myVar = If(someBooleanExpression, someValue, someOtherValue)
There are some subtle differences between IIf and If but I'll leave you to read about how If works for yourself.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am trying to refactor my VBA code. I am so used to using refactoring in Java-based IDEs for a number of years. Does VBA editor support any refactoring or are there any add-ins? MZ Tools did not have any such functionality.
I want to be able to do at least the following:
1. Rename variables
2. Split Procedures into sub-procedures to make the code more readable
3. Change the scope of the variable from global to procedure and vice-versa
Disclaimer: I'm heavily involved with this project.
Rubberduck is an open-source add-in for the VBA/VB6 IDE under [very] active development, that includes this functionality.
Version 1.3 includes a Rename refactoring:
Version 2.0 (beta available, still stabilizing) includes a dozen refactorings:
Introduce Parameter promotes a local variable to a parameter
Introduce Field promotes a local variable to module scope
Encapsulate Field turns a public field into a property
Move Closer to Usage moves a field that's only used in 1 procedure, into that procedure. Or moves a local variable immediately above its first use.
Extract Interface lets you pick what class members to extract into an interface, creates a new class modules with stubs for them, and makes the original class implement the extracted interface.
Implement Interface creates stubs for all members of an unimplemented interface, so you don't need to create them manually by selecting them one by one in the code pane dropdown:
Implements IClass1
Public Sub IClass1_DoSomething()
Err.Raise 5 'TODO implement interface member
End Sub
Public Function IClass1_GetFoo() As Integer
Err.Raise 5 'TODO implement interface member
End Function
Sub DoSomething()
End Sub
Function GetFoo() As Integer
End Function
More refactoring tools are on the project's roadmap (including Extract Method), which you can follow on GitHub.
The only 'refactoring' tool I know of in VBA is Ctrl+F and Ctrl+R.
I use V-Tools for refactoring-like work as it will do find / replace in objects, not just VBA code.
http://www.skrol29.com/us/vtools.php
Yes there is.... almost
In the good old days i used this one.
http://www.moshannon.com/speedferret.html
helped me alot and I think i have the 3.5" disks somewere ;)
The trick is to copy your excel code to Access or VB6 and do your refactoring there.
Replacing scope: solution is creative naming and using replace.
spitting procedures... well thats a manual I'm sorry.
It's usually not worth it unless you have some serious excel vba code, I would recoment converting most of it into c# or VB.Net dll where you can do refactoring, testing and some modern magic and only do as little you can in VBA.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Given a LGPL'ed grammar file, is the source generated by a compiler-compiler for the grammar a derivative works? What about if the grammar file was modified before it was given as input to the compiler-compiler? There isn't any linking, at least not in the conventional sense.
If the output is a derivitive work, must I then simply provide the (modified) grammer sources making any best efforts to ensure the grammar will function without dependencies imposed by the program/library using it? Or are there more restrictions which must be resolved?
1) Since the grammar contains the essence of the resulting code, it definitely belongs to "all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities" and is not a part of "the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work". In brief, LGPLv3 applies.
So, you need to convey the "Minimal Corresponding Source" (the one used to build the version in the Combined Work) according to sec.4 d) 0) or GPLv3 sec.6, mark it as modified if it is and possibly include custom tools if required by GPL's definition of "Corresponding Source". (In general, as sec.0 says, LGPLv3 is effectively GPLv3 with a few additional provisions.)
2) It might be a derivative work of the generator used as well if the latter inserts parts of itself into the code (see FSF FAQ#Can I use GPL-covered tools... to compile...?) - check the generator's workings and licensing terms if necessary. If it is, you'll have to satisfy both LGPLv3 and the generator's terms that apply to the results of its work.
The best answer, and which everyone should be giving you is as follows:
Contact a lawyer
Disclaimer: IANAL and if you want something "official" you should talk to one. That said...
A common-sense approach says that yes, the result of compilation of something that is compilable is a derivative work. For instance, the compiled version of an LGPL library is still LGPL - you can't say that you obtained a compiled version of the library and never compiled it yourself and somehow dodge providing the source code that way.
Thus, the LGPL would require you to distribute the (potentially modified) source of the original LGPL work, such that if an individual wanted to further modify the work, they could.